#定义负载均衡设备的 Ip及设备状态
proxy_pass http://myServer;
upstream 每个设备的状态:
down 表示单前的server暂时不参与负载
weight 默认为1.weight越大,负载的权重就越大。
max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误
fail_timeout:max_fails 次失败后,暂停的时间。
backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
upstream a.com{ # hash $cookie_jsessionid; hash $remote_addr consistent; server 192.168.142.128:8080 weight=3; server 192.168.142.129:80 weight=10; # hash $cookie_jsessionid; # server 192.168.142.130:80; # ip_hash; # hash_again 1; # consistent_hash $remote_addr:可以根据客户端ip映射 # consistent_hash $request_uri: 根据客户端请求的uri映射 # consistent_hash $args:根据客户端携带的参数进行映射 } server{ listen 80; server_name a.com; location / { index index.html; root /usr/html; proxy_pass http://a.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。