D
D
Danil Tunev2016-08-28 05:31:36
Nginx
Danil Tunev, 2016-08-28 05:31:36

Nginx 1.6.2 websocket connection issue?

Hello! Tell me what I'm doing wrong, system configuration: linux debian 8 (i386), nginx 1.6.2 (installed through the nginx-full package manager) + fastCGI. Prior to nginx 1.3.13, did you need to connect some third-party module? I got acquainted with the article: https://habrahabr.ru/post/171757/ , I set up the configuration in a simple and more complex way using the example. Initially, in the nginxa configuration, I tried to push unix:socket (for fastcgi) and proxy_pass website into one location, which nginx cursed, which led to the need for javascript to access another location, which, in turn, would send all ws:traffic to the above address . firefox writes:
Firefox is unable to connect to ws://46.222.222.234/aa. What am I doing wrong? There are suspicions that all the same, some kind of module needs to be installed. I found the lua-nginx-websocket module in the package manager, maybe there is some for fastcgi + c, although I tried to transfer everything to a clean html page, everything is the same. What could be the problem? There is nothing in the error logs.
here are the settings themselves:
location /aa{
proxy_pass 46.222.222.234/website;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /website{
#SOCKET STRING FOR fastcgi
fastcgi_pass unix:/tmp/fastcgi/socket;
#/
#proxy_pass unix:/tmp/fastcgi/socket;
include fastcgi_params;
}
и javascript код:
function f_a()
{
var socket = new WebSocket("ws://46.222.222.234/aa");
socket.onopen = function() {
a_1.innerHTML+=("Соединение установлено.
");
socket.send("hello_world!");}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serious911, 2016-08-28
@serious911

У меня работает такой конфиг:
location /websocket {
proxy_pass websockets/websocket;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket specific
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
proxy_buffering off;
proxy_connect_timeout 43200000;
proxy_read_timeout 43200000;
proxy_send_timeout 43200000;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question