【发布时间】:2018-03-18 08:51:57
【问题描述】:
我在 error.log 文件 nginx conf 文件中收到以下错误。
我正在尝试在节点 js 服务器上运行 nginx 服务器。
错误:连接上游时没有实时上游,客户端: 127.0.0.1,服务器:www.XYZ.com,请求:“GET / HTTP/1.0”,上游:“http://localhost/”,主机:“localhost”
Node js 服务器在 3000 端口上运行,nginx 在 80 端口上运行
nginx 配置文件是
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 128;
#gzip on;
server_names_hash_bucket_size 64;
client_header_timeout 3000;
client_body_timeout 3000;
fastcgi_read_timeout 3000;
client_max_body_size 32m;
fastcgi_buffers 8 128k;
fastcgi_buffer_size 128k;
server {
listen 80 ;
server_name XYZ.com;
location / {
# Base url of the Data Science Studio installation
proxy_pass http://localhost: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;
}
}
}
node js 服务器运行在 3000 端口
app.listen(3000);
看起来 nginx 正在尝试连接到默认端口 80 而不是 3000 上的节点 js 服务器。
请帮我解决这个问题。我花了很多时间,但没有运气。
谢谢
【问题讨论】:
-
我认为这个问题是你的节点服务器没有及时启动你可以添加`proxy_read_timeout 5m; `在nginx文件中
-
请运行
nginx -T并确保您没有获得其他配置 -
我尝试了这两个选项我仍然收到错误:上游超时(10060:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接主机没有响应)同时连接到上游,客户端:127.0.0.1,服务器:www.XYZ.com,请求:“GET / HTTP/1.0”,上游:“http://[::1]:80/ ", 主机: "本地主机"
-
将
nginx -T和sudo netstat -plant的输出添加到您的问题中