Nginx upstream负载均衡配置
1、在http节点下添加
upstream test {
server 127.0.0.1:16010;
server 127.0.0.1:16011;
}
2、把server 节点下 location 里 proxy_pass 的配置修改为 http://upstream名称 即 http://test
1 location / { 2 proxy_set_header X-Real-IP $remote_addr; 3 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 4 proxy_set_header Host $http_host; 5 proxy_set_header X-Nginx-Proxy true; 6 proxy_set_header Connection ""; 7 proxy_pass http://test; 8 }