2016-02-11 90 views
0

我尝试将路径转发到特定的url,我的websocket请求必须去。它听取端口8180.我发现Nico Kaiser的例子。Nginx Websocket反向代理抛出错误

我的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的服务器,如日志告诉我。

我必须改变什么才能正确地做出改变?

回答

2

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

二,

proxy_set_header连接“升级”;

应当使用大写字母 “U”

proxy_set_header连接 “升级”;

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