没用过 nginx 菜鸟想问问:
假如我服务器运行2个 nodejs 程序,一个是 localhost:3000,另一个是 localhost:8080
我能不能把域名 a.com 指向 localhost:3000,把域名 b.com 指向 localhost:8080?
天蓬老师2017-04-17 14:59:32
server{
listen 80;
server_name a.com;
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_pass http://127.0.0.1:3000;
proxy_redirect off;
}
}
server{
listen 80;
server_name b.com;
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_pass http://127.0.0.1:8080;
proxy_redirect off;
}
}
巴扎黑2017-04-17 14:59:32
Yes, nginx upstream reverse proxy
There happens to be an article
https://segmentfault.com/a/11...