這里拿Nginx和之前做的Tomcat 多實例來實現tomcat負載均衡
1.準備多實例與nginx
tomcat單機多實例部署-CSDN博客
2.配置nginx做負載均衡
?upstream tomcat{
? ? ? ? server 192.168.60.11:8081;
? ? ? ? server 192.168.60.11:8082;
? ? ? ? server 192.168.60.11:8083;? ? ? ? }
server {
? ? ? ? listen ? ? ? 80;
? ? ? ? server_name ?localhost;? ? ? ? #charset koi8-r;
? ? ? ? #access_log ?logs/host.access.log ?main;
? ? ? ? location / {
? ? ? ? ? ? root ? html;
? ? ? ? ? ? index ?index.php index.html index.htm;
? ? ? ? ? ? proxy_pass http://tomcat;
? ? ? ? }
3.測試
?配置成功!