首页 > 解决方案 > 在 nginx 代理中设置 Tomcat

问题描述

我正在设置我的网络服务器,我需要运行 tomcathttp://ip/tomcat/而不是http://ip:8080/. 我如何在 nginx 上做到这一点?我试图在互联网上找到答案,但所有这些对我来说都没用。

我的 nginx 配置:

upstream tomcat {
    server ip:8080;
}

server {

        listen 80 default_server;
        listen [::]:80 default_server;

        server_name _;

        location /tomcat/ {
                proxy_pass http://tomcat;
        }

}

服务器回答: 服务器回答图片

标签: nginxtomcatproxytomcat7

解决方案


使用下面的反向代理和测试。

location /tomcat/ {
                proxy_pass http://tomcat/;
        }

注意:IP 地址中需要使用 tomcat IP。


推荐阅读