Nginx,nodejs:上游超时(110:连接超时)

时间:2018-06-03 15:33:31

标签: node.js ubuntu nginx ubuntu-16.04

首先:Ubuntu 16.04.4,nginx作为反向代理,nodejs应用程序运行pm2,ssl证书来自let的加密。 我一直收到此错误:504网关超时。我重新安装了let的加密证书后 在错误nginx错误日志中我发现了这个:

2018/06/03 12:37:32 [error] 9128#9128: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxxxxx, server: cloudlandmusic.com, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:3000/", host: "cloudlandmusic.com"

这是我的nginx配置:/ etc / nginx / sites-enabled / default

# HTTP — redirect all traffic to HTTPS
server {
    listen 80;
    listen [::]:80 default_server ipv6only=on;
    return 301 https://$host$request_uri;
}

# HTTPS — proxy all requests to the Node app
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name cloudlandmusic.com;

    # Use the Let’s Encrypt certificates
    ssl_certificate /etc/letsencrypt/live/cloudlandmusic.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/cloudlandmusic.com/privkey.pem;

    # Include the SSL configuration from cipherli.st
    include snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://localhost:3000/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
    }
}

这是nginx状态:

nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2018-06-03 12:35:25 UTC; 16min ago
  Process: 8883 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
  Process: 9122 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 9118 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 9127 (nginx)
    Tasks: 2
   Memory: 2.1M
      CPU: 66ms
   CGroup: /system.slice/nginx.service
           ├─9127 nginx: master process /usr/sbin/nginx -g daemon on; master_process on
           └─9128 nginx: worker process

这是我试过的: 把它放到服务器配置中并尝试使用不同的组合

    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_read_timeout 3600;

proxy_read_timeout 300;
proxy_connect_timeout 300;

然后它给了我:502坏网关 我重新安装了nginx,每次更改配置时都重新启动但没有发生任何事情

0 个答案:

没有答案