【问题标题】:nginx reverse proxy with tomcat not working带有tomcat的nginx反向代理不起作用
【发布时间】:2017-10-22 06:21:35
【问题描述】:

我正在尝试使用 nginx 代理 tomcat。我在下面有这个配置。现在我面临的问题是,如果我通过 IP(192.168.2.6) 访问 url,那么它会被重定向到 /auth_app is tomcat,这很好。 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/; 
    } 

}

【问题讨论】:

    标签: java tomcat nginx proxy spring-saml


    【解决方案1】:

    在你的 tomcat 应用程序中应该有一个配置设置来将重定向 URL 设置为http://192.168.2.6/auth_app/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-15
      • 2019-06-05
      • 2018-01-20
      • 1970-01-01
      • 2020-06-23
      • 1970-01-01
      • 2021-09-15
      • 2018-05-09
      相关资源
      最近更新 更多