【问题标题】:starting node.js app with pm2 : bad gateway from proxy_verse server使用 pm2 启动 node.js 应用程序:proxy_verse 服务器的网关错误
【发布时间】:2016-04-10 21:08:27
【问题描述】:

在我的 server1 上,我将 nginx 作为 reverse_proxy 运行到 server2,它在端口 3000 上运行 node.js 应用程序(完整的 MEAN 堆栈)

当我用 grunt 启动 server2 时,一切都运行良好

-- server2 ---
cd /opt/mean
grunt  # running server.js , MEAN app

作为下一个学习步骤,我正在尝试使用 server2 上的 pm2 来监控我的测试网络应用程序。我安装了 pm2 并运行

-- server2 ---
cd /opt/mean
pm2 start server.js

得到了

        [PM2] restartProcessId process id 0
    [PM2] Process successfully started
    ┌──────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────────────┬──────────┐
    │ App name │ id │ mode │ pid  │ status │ restart │ uptime │ memory      │ watching │
    ├──────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────────────┼──────────┤
    │ server   │ 0  │ fork │ 2182 │ online │ 14      │ 0s     │ 10.867 MB   │ disabled │
    └──────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────────────┴──────────┘
     Use `pm2 show <id|name>` to get more details about an app
    yves@gandalf:/opt/mean$ pm2 show server
    Describing process with id 0 - name server
    ┌───────────────────┬─────────────────────────────────────────┐
    │ status            │ errored                                 │
    │ name              │ server                                  │
    │ id                │ 0                                       │
    │ path              │ /opt/mean/server.js                     │
    │ args              │                                         │
    │ exec cwd          │ /                                       │
    │ error log path    │ /home/yves/.pm2/logs/server-error-0.log │
    │ out log path      │ /home/yves/.pm2/logs/server-out-0.log   │
    │ pid path          │ /home/yves/.pm2/pids/server-0.pid       │
    │ mode              │ fork_mode                               │
    │ node v8 arguments │                                         │
    │ watch & reload    │ ✘                                       │
    │ interpreter       │ node                                    │
    │ restarts          │ 28                                      │
    │ unstable restarts │ 0                                       │
    │ uptime            │ 0                                       │
    │ created at        │ N/A                                     │
    └───────────────────┴─────────────────────────────────────────┘
    Process configuration

    Revision control metadata
    ┌──────────────────┬─────────────────────────────────────────────┐
    │ revision control │ git                                         │
    │ remote url       │ https://github.com/meanjs/mean.git          │
    │ repository root  │ /opt/mean                                   │
    │ last update      │ 2015-09-04T15:02:21.894Z                    │
    │ revision         │ 3890aaedf407151fd6b50d72ad55d5d7566a539b    │
    │ comment          │ Merge pull request #876 from codydaig/0.4.1 │
    │ branch           │ master                                      │
    └──────────────────┴─────────────────────────────────────────────┘

当我尝试在浏览器中请求我的应用程序时,我现在从 server1 收到一个错误

502 错误网关 nginx/1.4.6 (Ubuntu)

我是否必须在 nginx 默认配置中添加或更新任何内容,因为 proxy_pass 指令指向 http://:3000

非常感谢您的反馈和 2016 年新年快乐!

【问题讨论】:

    标签: node.js nginx mean-stack pm2


    【解决方案1】:

    “pm2 show”显示您的节点服务器出错,因此它可能没有运行。如果您跟踪错误日志,您会看到什么?它应该有一些关于这个问题的细节

    我认为代理错误可能是因为节点没有运行

    【讨论】:

    • 我想念那个!!! ,我应该从它开始:sudo pm2 start server.js 非常感谢
    猜你喜欢
    • 1970-01-01
    • 2016-12-10
    • 2016-06-11
    • 1970-01-01
    • 1970-01-01
    • 2015-05-18
    • 2016-04-10
    • 2018-12-20
    • 2016-02-11
    相关资源
    最近更新 更多