使用nginx容器作为反向代理时的原始url [英] Original url when using nginx container as reverse proxy
问题描述
我有一个Web应用程序作为一个停靠码头容器部署。我还有一个 nginx 容器(使用 dnsmasq 解析器)设置为在Web应用程序前面的反向代理,它的80端口映射到主机。我的应用程序使用SSO身份验证。
I have a web application deployed as a docker container. I also have an nginx container (using dnsmasq resolver) set up to act as a reverse proxy in front of the web application, it's 80 port mapped to the host. My application uses SSO authentication.
当我使用我的身份提供商登录时,回调URL似乎是我的Web应用程序的内部域名,而不是主机上的正确URL机器。
When I log in using my identity provider, the callback url seems to be my web application's internal domain name, not the proper url on the host machine.
我的nginx配置:
server {
resolver 127.0.0.1 valid=1s ipv6=off;
set $upstream_endpoint http://myapp:5000;
listen 80;
location / {
proxy_pass $upstream_endpoint;
}
}
sso尝试重定向的回调网址是 http:// myapp:5000 不是 http://myhost.com:80 ,这显然是因为它是内部的。
The callback url to which the sso tries to redirect is http://myapp:5000 not http://myhost.com:80, which is obviously fails since it is internal.
有人可以帮助我找到如何设置nginx正确吗?
Could somebody please help me find how to set nginx up properly?
推荐答案
将此指令添加到位置:
proxy_set_header主机myhost.com;
这篇关于使用nginx容器作为反向代理时的原始url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!