Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js nginx有时响应504/502网关超时错误_Node.js_Nginx_Server_Nginx Reverse Proxy - Fatal编程技术网

Node.js nginx有时响应504/502网关超时错误

Node.js nginx有时响应504/502网关超时错误,node.js,nginx,server,nginx-reverse-proxy,Node.js,Nginx,Server,Nginx Reverse Proxy,我面临一个问题 我有6个express应用程序在Node上运行,并使用Nginx作为反向代理,所有这些应用程序都可以正常运行数月。但最近,当我试图导航到任何站点的内部页面时,它返回了502或504 nginx错误 当我尝试在ngrok或本地运行应用程序时,它们工作正常,但在生产服务器上运行时,出现了504/502错误 Nginx日志说 2019/04/10 16:38:12[错误]1362#1362:*245从上游读取响应头时上游超时(110:连接超时),客户端:37.9.113.120,服务器

我面临一个问题

我有6个express应用程序在Node上运行,并使用Nginx作为反向代理,所有这些应用程序都可以正常运行数月。但最近,当我试图导航到任何站点的内部页面时,它返回了502或504 nginx错误

当我尝试在ngrok或本地运行应用程序时,它们工作正常,但在生产服务器上运行时,出现了504/502错误

Nginx日志说
2019/04/10 16:38:12[错误]1362#1362:*245从上游读取响应头时上游超时(110:连接超时),客户端:37.9.113.120,服务器:my.server,请求:“GET/videos/videoId HTTP/1.1”,上游:http://127.0.0.1:3000/videos/videoId,主持人:“www.my.host”

我试图增加超时时间

proxy_connect_timeout       600;
proxy_send_timeout          600;
proxy_read_timeout          600;
send_timeout                600;
但这没用(

这是我的服务器配置

server {
    listen x.x.x.x:443 http2;
    ssl on;

    server_name www.myservername.com;

...(ssl conf here)

    location / {
        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;
    }
}
我深入研究了StackOverflow类似的主题,但没有找到解决方案。在这种情况下,最奇怪的是,内部页面在一段时间后可用,但在我进行加载测试并在生产服务器上发送大约100个请求后,它会停止工作大约半个小时


提前感谢您的帮助。

您正在使用ssl收听443,您必须指定您的证书/密钥:

server {
    listen 443 ssl;
    server_name www.example.com;

    ssl_certificate     /var/lib/nginx/ssl/serverssl.crt;
    ssl_certificate_key /var/lib/nginx/ssl/serverssl.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!MD5;

    location / {
        proxy_set_header Host example.com;
        proxy_pass http://localhost:8192/;
    }
 }

您正在使用ssl侦听443,必须指定您的证书/密钥:

server {
    listen 443 ssl;
    server_name www.example.com;

    ssl_certificate     /var/lib/nginx/ssl/serverssl.crt;
    ssl_certificate_key /var/lib/nginx/ssl/serverssl.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!MD5;

    location / {
        proxy_set_header Host example.com;
        proxy_pass http://localhost:8192/;
    }
 }

当你直接从服务器上卷曲你的应用程序时,你有什么反应吗?CURL-X GET“”不幸的是,CURL或wget也没有反应(((你的应用程序运行在端口3000或3002上(nginx log show 3000,nginx conf show 3002)?重新启动你的应用程序,然后尝试卷曲/wget你的应用程序(不是nginx!)直接使用127.0.0.1和localhost:,如果您无法通过直接ip/lcoalhost访问您的应用程序,则问题出在应用程序端而不是nginx上。设置了一个输入错误。设置了3000端口。刚刚尝试执行curl,但仍然有相同的问题。wget或curl在我的计算机上的本地主机上工作,但在服务器上不工作。当您直接对应用程序进行curl时om服务器是否有任何响应?curl-X GET“”很遗憾,curl或wget也没有响应(((您的应用程序正在端口3000或3002(nginx log show 3000,nginx conf show 3002)上运行)?重新启动应用程序,然后尝试curl/wget您的应用程序(不是nginx!)127.0.0.1和localhost:的direclty,如果无法通过直接ip/lcoalhost访问应用程序,则问题出在应用程序端而不是nginx上。设置了配置中的键入错误。已设置3000端口。仅尝试执行curl,但仍然存在相同的问题。wget或curl在我的计算机上的localhost上工作,但在服务器上不工作。