Nginx负载均衡

1.增加集群主机

updtream appserver{
    server 192.168.0.100;
    server 192.168.0.101;
}

2.配置

location / {
                proxy_pass http://appserver;   #来自jsp请求交给tomcat处理
                proxy_redirect off;
                proxy_set_header Host $host;    #后端的Web服务器可以通过X-Forwarded-For>获取用户真实IP
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        } 

3.权重

updtream appserver{
    server 192.168.0.100 weight=1;
    server 192.168.0.101 weight=5;
}

4.backup和down
down不参与集群
backup备份主机

Last modification:August 12th, 2019 at 09:33 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment