[英]nginx reverse proxy with tomcat not working
I am trying to proxy tomcat using nginx. 我正在尝试使用nginx代理tomcat。 I have this configuration below. 我在下面有这个配置。 Now the problem I am facing is if I access the url by IP(192.168.2.6) then it gets redirected to /auth_app is tomcat which is perfectly fine. 现在我面临的问题是,如果我通过IP(192.168.2.6)访问url,那么它将被重定向到tomcat的/ auth_app,这是非常好的。 The tomcat url redirect to a third party SAML2 provider and once it authenticated it redirected to http://localhost:8080/auth_app/ instead of http://192.168.2.6/auth_app/ and because of that my application doesn't open as tomcat is running on 192.168.2.6 and not localhost. tomcat url重定向到第三方SAML2提供程序,并且在对其进行身份验证后将其重定向到http:// localhost:8080 / auth_app /而不是http://192.168.2.6/auth_app/ ,因此我的应用程序无法以tomcat在192.168.2.6而不是localhost上运行。
server {
listen 80 default_server;
server_name _;
error_log /var/log/nginx/abc_error.log;
access_log /var/log/nginx/abc_access.log;
rewrite ^/?$ /auth_app;
location /auth_app {
proxy_redirect off;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/auth_app/;
}
} }
在您的tomcat应用程序中应该有一个配置设置,用于将重定向URL设置为http://192.168.2.6/auth_app/
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.