K
K
kaneghost2017-05-25 17:10:33
Nginx
kaneghost, 2017-05-25 17:10:33

WebSocket Nginx HTTP/1.1 426 Upgrade Required?

Greetings!
The problem that burned the whole brain, the essence of which is that
On the VPS, openvpn was raised on the network of which resources were collected and brought to the outside world through Nginx reverse proxy and everything seemed to work with a bang until it was necessary to install KANBAN + GITLAB ( kanban.leanlabs. io/), which in turn uses WebSocket.
Having read in the documentation kanban.leanlabs.io/docs/configuration/webserver/nginx how to configure nginx to work, I did this, but received a dul in response.
An inquisitive brain led me to the idea of ​​raising the simplest chat on NODE.js + WebSocket, which was googled ( https://learn.javascript.ru/websockets) and done.
Everything works on the local machine, with a direct connection through a virtual network it also works. Through Nginx
nginx/1.12 no
header from browser

spoiler
GET / HTTP/1.1
Host: wiki.mirten.com
Connection: close
Pragma: no-cache
Origin: file://
Sec-WebSocket-Version: 13
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4
Sec-WebSocket-Key: mFkeKOadrRoJ5k9ty6/KwQ==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Via: 1.1 localhost (squid)
Cache-Control: no-cache

header from server:
spoiler

HTTP/1.1 426 Upgrade Required
Content-Length: 16
Content-Type: text/plain
Date: Thu, 25 May 2017 14:05:31 GMT
Connection: close
Upgrade Required

config:
map $http_upgrade $connection_upgrade {
        default upgrade;
        ""      close;
}
#upstream websockets{
#       server 10.8.0.115:9081;
#}
server {
    listen       80;
    server_name  wiki.mirten.com;

    access_log /var/log/nginx/acc_chat2.log;
    error_log /var/log/nginx/err_chat2.log;
    client_max_body_size 200G; # максимальный файл для загрузки



    location /ws {
        proxy_pass http://10.8.0.115:9081/;
        proxy_http_version 1.1;
        proxy_set_header Host $host;

        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        #proxy_set_header Upgrade $http_upgrade;
        #proxy_set_header Connection "upgrade";

        #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        #proxy_read_timeout 86400;
        #proxy_set_header X-Real-IP $remote_addr;
        #proxy_buffering off;
    }


 }

Help me find the error friends!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question