编辑nginx.conf
nginx实现负载均衡
upstream nodejs {
server 127.0.0.1:8091;
server 127.0.0.1:3001;
server 47.x.x.x:3000;
keepalive 64;
}
server {
listen 80;
server_name xxx.com;
access_log logs/node.test.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Nginx-Proxy true;
proxy_set_header Connection "";
proxy_pass http://nodejs;
}
}
反向代理
server {
listen 80;
server_name aaa.com;
server_name bbb.com;
server_name ccc.com;
access_log logs/node.test.log;
location ^~ /aaa{
proxy_pass http://aaa.com;
}
location ^~ /bbb{
proxy_pass http://bbb.com;
}
location ^~ /ccc{
proxy_pass http://ccc.com;
}
}