Comments (7)
@carmas123 i have done some tests on my local machine and everything works properly (PS done tests only with ws
). Just to note nginx is very strict with url /
ending:
My working example:
server {
listen: 3000;
server_name: localhost;
location /ws/ {
access_log on;
proxy_pass http://127.0.0.1:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Proxy "";
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;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_cache_bypass $http_upgrade;
}
}
// JS client connects to
let socket = new ClusterWS({
url: `ws://127.0.0.1:3000/ws/`
})
// ClusterWS 4 server specifies WSPath as `/`
new ClusterWS({
....
websocketOptions: {
wsPath: "/",
}
....
})
As soon as i remove even one /
anywhere, i will get broker connection with error 400 or 502. Please make sure you have correct urls everywhere including /
at the end.
Broken Examples:
location /ws/ {
access_log on;
proxy_pass http://127.0.0.1:3001; <- Note just removed `/` and it is broken
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Proxy "";
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;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_cache_bypass $http_upgrade;
}
// JS client connects to
let socket = new ClusterWS({
url: `ws://127.0.0.1:3000/ws/`
})
Or
location /ws/ {
access_log on;
proxy_pass http://127.0.0.1:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Proxy "";
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;
proxy_set_header Host $host;
proxy_set_header X-NginX-Proxy true;
proxy_cache_bypass $http_upgrade;
}
// JS client connects to
let socket = new ClusterWS({
url: `ws://127.0.0.1:3000/ws` <- Just remove `/` and it does not work any more
})
Would suggest to try playing around with configs and correct path configurations also try changing localhost
to 127.0.0.1
and otherwise to see if that will help.
Let me know how it goes 😄
from clusterws.
I solved and I'll tell you later a fullworking solution. With Nginx we need to rewrite the $schema
from clusterws.
👍
from clusterws.
Ok, I solved adding this string into location key of Nginx:
proxy_redirect https:// $scheme://;
Happy coding to all :)
from clusterws.
@carmas123 Thanks will keep in mind I am going to pin this issue.
from clusterws.
I think that this is not a ClusterWS problem, but this occurs because web socket filter only wss/ws schema to handle websocket and other to handle all other requests.
If nginx translate the source wss:// schema to https:// obviously it does not work.
from clusterws.
Yes, that would be still very useful to keep pinned as question
there are surely would be others who can have similar problem with Nginx configs as it is very popular proxy 😄
from clusterws.
Related Issues (20)
- Is it possible create different (non clone) processes? HOT 4
- Close/Stop/Kill the server HOT 1
- How to determine which process current code is running in. HOT 7
- Having interest in translate document to zh-CN HOT 7
- Plz add `upgradeReq` argument, let it back HOT 1
- Can I store a dictionary in memory accessed from each workers? HOT 4
- How to upload files? HOT 4
- Publish to channel but only to some users HOT 5
- Callback in verify connection middleware HOT 6
- How to send msg by userid connection? HOT 1
- Del
- Websockets inside a cluster, ok in production? HOT 2
- Callback issue on verifyConnection middleware HOT 12
- benchmark & does it work on browser too ? HOT 2
- uws not compiled for node 7.2
- How to see the list of channels a client is subscribed to HOT 3
- Don't understand what .processMessage is for? HOT 5
- Middleware.onPublishIn ? HOT 1
- TypeError: this.options.logger.warning is not a function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clusterws.