Node.js nginx和同一域下的Nodejs应用程序
我试图在同一个域下为两个nodejs应用程序提供服务,我像这样配置nginxNode.js nginx和同一域下的Nodejs应用程序,node.js,express,nginx,Node.js,Express,Nginx,我试图在同一个域下为两个nodejs应用程序提供服务,我像这样配置nginx server { listen 80; location /client { proxy_pass http://127.0.0.1:3000; proxy_redirect off; proxy_set_header Host $host; proxy_set_head
server {
listen 80;
location /client {
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
proxy_pass http://127.0.0.1:3001;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
我可以连接到第二个应用程序,即端口3001上的应用程序,但我无法连接到端口3000(App1)上的应用程序,我得到了502坏网关
App1正在express 4.x上运行,是否还有其他配置
server {
listen 80;
root /var/www;
server_name your-domain.com;
location /app1 {
proxy_pass http://localhost:{YOUR_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /app2 {
proxy_pass http://localhost:{YOUR_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
尝试与上面类似的配置