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.****.net/detail/zz_cl/9857215