# nginx开启负载均衡
nginx.conf 配置文件如下:
upstream myServerSetting {
server 127.0.0.1:8081 weight=5;
server 127.0.0.1:8082 weight=2;
server 127.0.0.1:8082 weight=2;
ip_hash; #每个ip只对应一个server,避免session问题
fair; #性能时间响应优先
}
1
2
3
4
5
6
7
2
3
4
5
6
7
location / {
proxy_pass http://myServerSetting;
root html;
index index.html index.htm;
}
1
2
3
4
5
2
3
4
5