CentOS起两台tomcat,端口分别是8080和8081!
1.
nginx配置文件:nginx.conf
upstream tomcats{ server 192.168.198.128:8080; server 192.168.198.128:8081; } server { listen 80; server_name tomcat.taobao.com; location / { proxy_pass http://tomcats; index index.html index.htm; } }
当然了,需要配一下hosts,使用这个好工具
上述情况负载均衡的处理
只需要在upstream的server后面添加一个weight即可代表权重。权重越高,分配请求的数量就越多。默认权重是1
upstream tomcats{ server 192.168.198.128:8080 weight=5; server 192.168.198.128:8081; } server { listen 80; server_name tomcat.taobao.com; location / { proxy_pass http://tomcats; index index.html index.htm; } }