我尝试将路径转发到特定的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;
}
当我尝试连接到网址时,错误为:*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服务器,正如日志告诉我的那样。
我需要改变什么才能做到正确?
答案 0 :(得分:2)
首先,它听起来像domain.de在该端口上没有正确响应。如果这是托管两者的同一服务器,则可能需要将其更改为localhost。
其次,
proxy_set_header连接“升级”;
应该使用大写“U”
proxy_set_header连接“升级”;
大写和小写U之间的这种区别没有在任何地方记录,但有些服务器需要一个,有些服务器没有区别。