我想在一个端口上设置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;
}
}
出了什么问题?
答案 0 :(得分:1)
您应该更正proxy_pass
,因为您是将请求代理回给nginx本身。
根据您的配置,它必须是
proxy_pass http://node/;
答案 1 :(得分:0)
您可能需要添加:
proxy_responses 0;
给你nginx配置。