N
N
nurdus2017-08-13 01:37:48
Nginx
nurdus, 2017-08-13 01:37:48

How to proxy websocket (recommendations that I found do not help)?

Good day.
I can't proxy websocket in any way. The connection goes through the port (ws://api.domain.com:3501), but not through the proxied port 80 (ws://api.domain.com). Can anyone suggest what could be the issue? Where could I go wrong?
nginx config

server {
    listen 80;
    root /var/www/domains/domain.com;
    server_name api.domain.com;
    location / {
        proxy_pass http://127.0.0.1:3501;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Tried a more "complex" setup:
http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }
#...

It writes in the logs:
[error] 17984#0: *25 connect() failed (111: Connection refused) while connecting to upstream, 
client: 10.0.0.185, server: api.domain.com, request: "GET / HTTP/1.0", 
upstream: "http://127.0.0.1:3501/", host: "api.domain.com"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
littleguga, 2017-08-13
@littleguga

1. Try
to change to
2. Show the output:
sudo netstat -lntup

N
nurdus, 2017-08-13
@nurdus

Tried netstat below

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8888            0.0.0.0:*               LISTEN      112/python
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      533/master
tcp        0      0 0.0.0.0:1443            0.0.0.0:*               LISTEN      110/python
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/init
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      660/nginx: master p
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      228/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      533/master
tcp6       0      0 :::3306                 :::*                    LISTEN      225/mysqld
tcp6       0      0 :::3501                 :::*                    LISTEN      902/node
tcp6       0      0 :::80                   :::*                    LISTEN      660/nginx: master p
tcp6       0      0 :::21                   :::*                    LISTEN      552/proftpd: (accep
tcp6       0      0 :::22                   :::*                    LISTEN      228/sshd

The only suspicion is that this is due to the fact that the ip is not dedicated, although without a dedicated line I have a python site proxied.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question