如何解决docker 中的 nginx 反向代理不起作用
我正在尝试使用 nginx 作为 docker 容器中的反向代理服务器,但我正在处理一些问题
server {
listen 80;
server_name test.mydomain.com;
location / {
proxy_pass http://my-internet-site.mydomain.com;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
}
出于某种原因,当我不使用 proxy_set_header 时一切正常,但我需要在不更改浏览器中的 URL 的情况下代理请求。
所以 test.mydomain.com 需要出现在 URL 栏中,而不是 my-internet-site.mydomain.com
有人可以帮我吗?
编辑
我的网站部署在外部平台上,也有反向代理。我只是添加了一些 itens,然后它就起作用了
proxy_ssl_server_name on;
proxy_redirect https://my-internet-site.mydomain.com http://test.mydomain.com;
proxy_redirect http://my-internet-site.mydomain.com http://test.mydomain.com;
proxy_set_header Host my-internet-site.mydomain.com;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。