【发布时间】:2023-12-24 01:47:02
【问题描述】:
我正在尝试将 Nginx 设置为反向代理,以访问在同一服务器上运行的多个 NodeJS 应用程序。
我的 nodeJS 应用程序在 PM2 上运行,一切看起来都很好:
我的 nodeJS 应用是使用 express-generator 生成的简单 nodeJS 应用,所以它应该在 3000 端口上运行。
我还使用以下配置设置了我的 Nginx
server {
listen 1004;
server_name pumadashboard.com;
location / {
proxy_pass http://127.0.0.1:3000;
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;
}
}
但是,当我 curl 127.0.0.1:1004 时,我从 Nginx 收到 badGateway 错误。我也无法从本地网络上的任何地方访问 pumadashboard.com,它只会加载直到超时。
【问题讨论】:
-
标题具有误导性。如果你从 nginx 收到错误,它肯定会监听端口。检查nginx的error.log