【问题标题】:Nginx Websocket reverse proxy throws errorNginx Websocket反向代理抛出错误
【发布时间】:2016-05-22 13:03:55
【问题描述】:

我尝试将路径转发到特定的 url,我的 websocket 请求必须去那里。它监听 8180 端口。我从Nico Kaiser 中找到了示例。

我的 nginx 配置现在如下所示:

location /sideview/frontend {
    access_log off;

    proxy_pass http://domain.de:8180;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # WebSocket support (nginx 1.4)
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    # Path rewriting
    rewrite /sideview/frontend/(.*) /$1 break;
    proxy_redirect off;
}

当我尝试连接到 URL 时,错误:*2508595 no live upstreams while connecting to upstream, client: 87.79.66.136, server: domain.de, request: "GET /sideview/frontend/ws HTTP/1.1", upstream: "http://domain.de/ws", host: "domain.de"

正如日志告诉我的那样,请求也没有到达 websockets 服务器。

为了让它正确,我必须改变什么?

【问题讨论】:

    标签: nginx proxy websocket


    【解决方案1】:

    首先,听起来 domain.de 在该端口上没有正确响应。如果这是托管两者的同一台服务器,您可能需要将其更改为 localhost。

    第二,

    proxy_set_header 连接“升级”;

    应使用大写“U”

    proxy_set_header 连接“升级”;

    大写和小写 U 之间的区别在任何地方都没有记录,但有些服务器需要一个,有些则不做区分。

    【讨论】:

      猜你喜欢
      • 2014-05-18
      • 2019-06-26
      • 2019-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      • 2016-03-12
      • 2016-12-20
      相关资源
      最近更新 更多