nginx负载均衡 upstream

主配置 nginx.conf

http{
    # 负载列表
    upstream servers {
       server    localhost:3301;
       server    localhost:3302;
    }
     
    server {
        listen       8080;
        server_name  localhost;

        location / {
            # 访问使用代理 servers 列表
            proxy_pass http://servers;
        }
     }

}

代理1:3301

server {
    listen      3301;
    server_name www.xxx.com;
    root /www/upstream/;
    
    index 1.html;
}

代理2:3302

server {
    listen      3302;
    server_name www.xxxx.com;
    root /www/upstream/;
    
    index 2.html;
}

访问:localhost:8080

你可能感兴趣的:(nginx负载均衡 upstream)