-
主要配置
http { upstream myhtml { server 106.52.147.100; server 106.52.147.101; } server { listen 80; server_name abc.wsycoon.cn; location / { proxy_buffering off; proxy_pass http://myhtml; } } }
1.轮询(down)
检查服务器是否有down,如果有电脑服务器不做负载。
upstream myhtml { server 106.52.147.100 down; server 106.52.147.101; }
2.权重(weight)
分配服务器访问的次数,越大代表请求次数越多
upstream myhtml { server 106.52.147.100 weight=1; server 106.52.147.101 weight=10; }
3.session问题(ip_hash)
同一个ip只请求同一台服务器
upstream myhtml { ip_hash; server 106.52.147.100; server 106.52.147.101; }
4.时间问题(fair)
根据加载时间的长短,进行自动分配
upstream myhtml { server 106.52.147.100; server 106.52.147.101; fair; }
5.同一url
upstream myhtml { server 106.52.147.100; server 106.52.147.101; hash $request_uri; }