配置nginx.conf 在最后添加如入:
stream { upstream 7000 { hash $remote_addr consistent; server 12.12.12.12:7000 max_fails=3 fail_timeout=30s; } upstream 7001 { hash $remote_addr consistent; server 12.12.12.12:7001 max_fails=3 fail_timeout=30s; } upstream 7002 { hash $remote_addr consistent; server 12.12.12.12:7002 max_fails=3 fail_timeout=30s; } upstream 7003 { hash $remote_addr consistent; server 12.12.12.12:7003 max_fails=3 fail_timeout=30s; } server { listen 7000; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass 7000; } server { listen 7001; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass 7001; } server { listen 7002; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass 7002; } server { listen 7003; proxy_connect_timeout 1s; proxy_timeout 3s; proxy_pass 7003; } }
nginx 重启
#pkill -9 nginx 强行结束进程
# /usr/local/nginx/sbin/nginx 启动进程