负载均衡
upstream WEB_SERVER {
ip_hash;
server 10.137.172.201;
server 10.137.172.202;
server 10.137.172.203;
}
location ~ ^/(.*)$ {
proxy_pass http://WEB_SERVER;
}
反向代理
upstream APP_SERVER {
ip_hash;
server 10.137.172.204:3000;
server 10.137.172.205:3000;
}
location ~ ^/apps/(.*)$ {
proxy_set_header x-real-ip $remote_addr;
proxy_pass http://APP_SERVER/$1?$query_string;
}
socket.io
upstream SOCKET_SERVER {
ip_hash;
server 10.137.172.204:3001;
server 10.137.172.205:3001;
}
location /socket.io/ {
proxy_pass http://SOCKET_SERVER$request_uri;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
}