【问题标题】:nginx -- no live upstreams while connecting to upstreamnginx -- 连接到上游时没有实时上游
【发布时间】:2020-10-21 23:35:51
【问题描述】:

我的 CentOS 7 服务器上安装了 nginx 版本 1.19.3。我的 Rocketchat 应用程序在端口 3000、3001 和 3002 上工作。但是我的 nginx 服务器无法将代理路由到 Rocketchat。它给了我 502 Bad Gateway 错误。

这是我的默认配置文件

# Upstreams
upstream backend {
    least_conn;
    server [::1]:3000 max_fails=3 fail_timeout=30s;
    server [::1]:3001 max_fails=3 fail_timeout=30s;
    server [::1]:3002 max_fails=3 fail_timeout=30s;
}

# HTTPS Server
server {
    listen 443 ssl http2;
    server_name example.com;
    error_log /var/log/nginx/rocketchat.access.log;
    ssl_certificate /etc/nginx/certs/example.com.crt;
    ssl_certificate_key /etc/nginx/certs/example.com.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE
    location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Nginx-Proxy true;
        proxy_read_timeout 5m;
        proxy_pass http://backend;
        proxy_redirect off;
    }
}

这是我在/var/log/nginx/rocketchat.access.log 中遇到的错误

2020/10/21 16:08:23 [error] 12532#12532: *25 no live upstreams while connecting to upstream, client: local-ip-address, server: example.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://backend/favicon.ico", host: "example.com", referrer: "https://example.com/"

我已经启用了3000、3001、3002,我可以通过本地IP地址访问RocketChat。

我已经尝试了通过 stackoverfollow 找到的所有解决方案,但它不起作用。有人知道可能是什么问题吗?

【问题讨论】:

    标签: nginx nginx-upstreams


    【解决方案1】:

    您的 Rocketchat 应用是否在 IPv6 本地主机地址 ::1 或 IPv4 127.0.0.1 上运行/可访问?

    【讨论】:

    • 我通过像 192.168.1.5 这样的本地网络访问,但如果我使用 telnet 127.0.0.1 3000。它返回我连接的响应。顺便说一句,我已经在上游尝试了 127.0.0.1。
    【解决方案2】:

    通过在上游将 keepalive 设置为 8 对我有用。

    # Upstreams
    upstream backend {
        least_conn;
        server [::1]:3000 max_fails=3 fail_timeout=30s;
        server [::1]:3001 max_fails=3 fail_timeout=30s;
        server [::1]:3002 max_fails=3 fail_timeout=30s;
        keepalive 8;
    
    }
    

    【讨论】:

      猜你喜欢
      • 2022-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-18
      • 2018-09-20
      • 2012-10-24
      • 2016-05-08
      • 2011-08-01
      相关资源
      最近更新 更多