nginx+tomcat反向代理

第一步:编辑nginx的配置文件

   
#服务转发一
    upstream tomcat8080{
        server 192.168.1.6:8080;
        
    }
#服务转发二
    upstream tomcat8081{
        server 192.168.1.6:8081;
    }
    

 #配置虚拟主机
    server {
        listen      80;
        server_name  www.testaaa.com;
        location / {
            #root   /usr/local/nginx/html-01;
           proxy_pass http://tomcat8080;
            index  index.jsp index.htm;
        }

   }

    
 #配置虚拟主机
    server {
        listen       80;
        server_name  www.testbbb.com;

        location / {
            #root   /usr/local/nginx/html-02;
            proxy_pass http://tomcat8081;    
            index  index.jsp index.htm;
        }

    }

第二步:编辑tomcat的文件 ,复制一份tomcat  并且修改tomcat的端口号,以及管理首页的标题

 

然后访问不同服务名称,此时出现如下界面 testaaa 域名的服务页面上有修改过的8081端口号

原文地址:https://www.cnblogs.com/shenwenbo/p/8289310.html