nginx负载均衡

说明:

xx.com可以是内网地址,也可以是公网地址

一. *.conf 配置

upstream xx.com{
    server 127.0.0.1:8006 fail_timeout=5s max_fails=1;
    server 127.0.0.1:8007 fail_timeout=5s max_fails=1;
    server 127.0.0.1:8008 fail_timeout=5s max_fails=1;
    server 127.0.0.1:8009 fail_timeout=5s max_fails=1;
    server 127.0.0.1:8010 fail_timeout=5s max_fails=1;
    server 127.0.0.1:8011 fail_timeout=5s max_fails=1;
    server 127.0.0.1:8012 fail_timeout=5s max_fails=1;
    server 127.0.0.1:8013 fail_timeout=5s max_fails=1;
}

server {
    listen 8005;
    server_name localhost;

    location / {
        proxy_pass http://xx.com;
        proxy_redirect default;
        proxy_connect_timeout 2s;
    }
}

参考地址:

https://blog.csdn.net/weixin_43184769/article/details/90899726