nginx配置多个tomcat

参考:http://blog.csdn.net/vio4677/article/details/43231693


一台linux服务器有多个tomcat服务,多个端口不容易记忆,可以使用nginx反向代理,用一个端口访问到所有的tomcat服务。只需要安装一个nginx,然后配置反向代理即可。

安装nginx这里不在重复。安装好以后修改配置文件,在conf目录下的nginx.conf文件,server里配置反向代理的tomcat信息:

    server {
  #监听的端口
        listen       10001;
        server_name  192.168.1.221;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location /nrhcm { //配置反向代理的第一个tomcat服务
            root   html;
            proxy_pass  http://192.168.1.221:8080/nrhcm;
            proxy_set_header           Host $host;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header           X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size  100m;
            index  index.html index.htm;
        }

        location /dhcms {//配置反向代理的第一个tomcat服务
            root   html;
            proxy_pass  http://192.168.1.221:8080/dhcms;
            proxy_set_header           Host $host;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header           X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size  100m;
            index  index.html index.htm;
        }


配置完成以后重启nginx,然后就可以访问了

http://192.168.1.221:10001/nrhcm 访问nrhcm 服务

http://192.168.1.221:10001/dhcms访问dhcms服务

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值