简体   繁体   中英

how to open ws protocol in nginx server?

我在socket.ibrahimyilmaz.me(我更改为tornado websocket示例)上运行了一个简单的聊天服务器,在本地,我可以访问服务器ws://127.0.0.1:8888,但是在生产环境中,我只能通过http到达,但是我希望能够在Nginx服务器上使用ws协议。

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        # the usual stuff...

        location /chat/ {
            proxy_pass http://backend;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }
    }

Source: http://nginx.org/en/docs/http/websocket.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM