nginx默认设置
upstream abc { server localhost:52816 weight=5 max_fails=2 fail_timeout=600s; server localhost:52817 weight=5 max_fails=2 fail_timeout=600s; } server { listen 80; server_name localhost; location / { proxy_pass http://abc; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 10; } }
其他的通用,监听80端口,导向abc,然后均衡负载至52816,52817,weight=5,轮询机制;
max_fails=2 fail_timeout=600s;,1个小时内如果有2次失败,后续将不在访问此端口。
测试是有效的。
proxy_connect_timeout 10;
10s秒时间访问失败自动切换,测试时,调换各个参数,发现实际是2倍的10s即20秒左右才自动切换,不晓得为什么,