【问题标题】:Can't configure nginx as a proxy for tomcat with context path无法将 nginx 配置为具有上下文路径的 tomcat 代理
【发布时间】:2016-05-26 11:02:50
【问题描述】:

http://localhost:8080/application 上拥有可访问应用程序的 Tomcat。

希望通过 url http://app.ru 访问此应用程序。所以这里是 nginx 代理配置:

server {
    server_name app.ru .app.ru;
    listen 80;
    location / {
        proxy_pass http://localhost:8080/application;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

移动到http://app.ru时,返回302重定向到http://app.ru/application

如何解决?

【问题讨论】:

  • 我认为你的 proxy_pass 指令需要一个斜杠。试试:proxy_pass http://localhost:8080/application/;this
  • 太棒了,它有效!谢谢!请将您的评论转换为答案,以便我接受

标签: tomcat nginx proxy


【解决方案1】:

感谢@Richard Smith 的评论。我忘记了结尾的斜线。

【讨论】:

    猜你喜欢
    • 2018-03-18
    • 2019-11-11
    • 2012-10-14
    • 1970-01-01
    • 2011-10-22
    • 2017-05-05
    • 1970-01-01
    • 2012-05-12
    • 2015-12-14
    相关资源
    最近更新 更多