April 18, 2020 05:39PM
Hello,

I’ve a websocket (wss) connection issue (status 200 instead 101) between a “server” (running nginx/1.14.2 reverse proxy) and a “black box” (running nginx/1.8.1 web server with websocket).

The “server” has access to Internet and to the local network where is connected the “black box”. I called it “black box” because I can’t change anything except the nginx config file.

From local network, the nginx web site of the “black box” is working properly including websocket connection.

From Internet, the “server”, the nginx reverse proxy gives me an access to the nginx web site of the “black box” everything works except the websocket, from my web browser I receive a status 200 but I should get 101 switching protocol.

I’ve tried different setup without success.

Please let me know what you think,

Thanks a lot,

Regards,
YAGA

The “black box” wss websocket uses 80 (which is not usual) and its https website uses 443.

“black box” web server nginx config (extract)

server {
listen 443 ssl;
ssl_certificate /opt/xxx/cert.crt;
ssl_certificate_key /opt/xxx/cert.key;

server_name localhost;
proxy_buffering off;

location / {
root /opt/xxx/web;
try_files $uri $uri/ /index.html;
}
location /websocket {
proxy_pass https://127.0.0.1:80;
}
location /api/ {
proxy_pass https://127.0.0.1:80;
}
location /static/ {
root /opt/xxx/website;
expires 10d;
}


“server” reverse proxy nginx config (extract)

server {
listen 443 ssl;
listen 80 ssl;
server_name my_server.xyz;
client_max_body_size 100M;
proxy_buffering off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
location / {
proxy_pass https://192.168.1.20/;
auth_basic "Private";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location /api/ {
proxy_pass https://192.168.1.20:80/api/;
auth_basic off;
}
location /websocket {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_http_version 1.1;
proxy_set_header Origin "";
proxy_pass https://192.168.1.20:80/;
auth_basic off;
}
}
Subject Author Posted

Websocket (wss) connection issue (status 200 instead 101) between two nginx systems

YAGA April 18, 2020 05:39PM

Re: Websocket (wss) connection issue (status 200 instead 101) between two nginx systems

Francis Daly April 19, 2020 02:56PM

Re: Websocket (wss) connection issue (status 200 instead 101) between two nginx systems

YAGA April 20, 2020 05:06PM

Re: Websocket (wss) connection issue (status 200 instead 101) between two nginx systems

Francis Daly April 22, 2020 03:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 79
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready