question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Websocket configuration

See original GitHub issue

What is troubling you? I’m struggled to configure websocket nginx on my NPM: https://extiverse.com/extension/kyrne/websocket

That’s my current config:

image

image

image

Full Custom Nginx Configuration:

proxy_hide_header Upgrade;
proxy_hide_header X-Powered-By;
add_header Content-Security-Policy "upgrade-insecure-requests";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Cache-Control "no-transform" always;
add_header Referrer-Policy no-referrer always;
add_header X-Robots-Tag none;

location @ws {
proxy_pass http://$server:1234;
proxy_set_header Host $http_host;
proxy_read_timeout     60;
proxy_connect_timeout  60;
proxy_redirect         off;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

Where 1324 is the port of my websocket application.

Unfortunately - I can’t establish connection. From browser console:

Pusher :  : ["Connecting",{"transport":"ws","url":"wss://dev.mywebsite.com:443/app/(...)?protocol=7&client=js&version=5.1.1&flash=false"}]

WebSocket connection to 'wss://dev.mywebsite.com/app/(...)?protocol=7&client=js&version=5.1.1&flash=false' failed: Error during WebSocket handshake: Unexpected response code: 404

I can connect into it without proxy like: wss://dev.mywebsite.com:1234

What I’m doing wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
conichonhaacommented, Feb 27, 2022

Is it possible to write a documentation for websocket? There’s only a few article with npm and websocket. I’ve got a fully functional websocket but when I try to migrate from my old nginx reverse proxy to npm, I can’t set the websocket part correctly

2reactions
GurjinderSinghcommented, Mar 5, 2021

I have solved my same problem by adding inside location block. password protect domain with access and https enabled. now both works like well-oiled engine.

  location /theiaphp {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_pass       http://theiaphp:3000/;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;
  }

  location /ubuntuvnc {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_pass       http://ubuntuvnc:80/;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure WebSocket connections
Create a WebSocket handler · In the Policy Studio tree, select a list of relative paths (for example, Environment Configuration > Listeners >...
Read more >
Using WebSocket to build an interactive web application
Click Dependencies and select Websocket. Click Generate. Download the resulting ZIP file, which is an archive of a web application that is configured...
Read more >
Configure WebSocket connections
Configure a WebSocket connection · In the Policy Studio tree, select a list of relative paths (for example, Listeners > API Gateway >...
Read more >
WebSocket Connection Configuration - Oro Documentation
Configure a Web Server to ensure messages interaction between the WebSocket server and the clients. ; Configure WebSocket-Related Application Parameters to ...
Read more >
Writing WebSocket client applications - Web APIs | MDN
This simple example creates a new WebSocket, connecting to the server at wss://www.example.com/socketserver . A custom protocol of "protocolOne" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found