nginx+tomcat服务集群

nginx官网下载最新稳定版的nginx


解压后修改nginx.conf配置文件,添加

#服务器的集群
    upstream  nginx.com {  #服务器集群名字
server    127.0.0.1:18080  weight=1;#服务器配置   weight是权重的意思,权重越大,分配的概率越大。
server    127.0.0.1:28080  weight=2;
}
location / {
            proxy_pass http://nginx.com;
            proxy_redirect default;
        }

准备两个tomcat,修改对应server.xml端口

tomcat1:
 <Connector port="18080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
<Connector port="8019" protocol="AJP/1.3" redirectPort="8443" />
tomcat2:
 <Connector port="28080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
<Connector port="8029" protocol="AJP/1.3" redirectPort="8443" />

启动两个tomcat

启动nginx,访问localhost/index.jsp:127.0.0.1:18080/index.jsp+127.0.0.1:28080/index.jsp
cd nginx根目录文件路径(定位)
访问所在盘符
nginx.exe
start nginx
nginx -s quit
nginx -s stop
nginx -s reload


刷新url地址,请求会被比例分配到不同的tomcat中。

http://download.csdn.net/detail/zz_cl/9857215

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zz_cl

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值