【问题标题】:Proxy from nginx to node - not enough worker connections从 nginx 到节点的代理 - 没有足够的工作连接
【发布时间】:2026-01-18 12:50:01
【问题描述】:

我想设置 nginx 服务器在一个端口上侦听,将连接代理到 nodejs 应用程序的不同端口。问题是我收到500 错误 - worker_connections are not enough while connecting to upstream

Nginx 配置:

upstream node {
        server 127.0.0.1:1235;
        keepalive 8;
}

server {
        listen 1234;
        server_name http://123.123.123.123:1234 node;
        access_log off;

        location / {
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                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://123.123.123.123:1234/;
                proxy_redirect off;
        }
}

怎么了?

【问题讨论】:

标签: node.js nginx proxy


【解决方案1】:

您应该更正您的 proxy_pass,因为您正在将请求代理回 nginx 本身。

根据你的配置应该是

proxy_pass http://node/;

【讨论】:

    【解决方案2】:

    您可能需要添加:

    proxy_responses 0;
    

    给你 nginx 配置。

    【讨论】:

    • 但是为什么呢?
    最近更新 更多