-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Socket SSL #134
Comments
+1 |
You can achieve this by settings the client_port to 443 in your settings, and putting an Nginx instance in front of node.js. Since Nginx 1.3.1 (i believe), it is capable of proxying websockets (wss too). This is my current setup, and it works fine. |
could you describe you nginx conf and end to end setup plz ? |
You need NginX 1.3.13 to proxy websockets. I use Ubuntu 12.04LTS, and got the latest version from the NginX PPAs NginX config: upstream subway {
server localhost:3000;
}
server {
listen 443 ssl;
server_name irc.reallysecretdomain.nl;
ssl_certificate cert.crt;
ssl_certificate_key cert.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://subway;
# These three seem to be specific to proxying websockets.
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $proxy_host;
proxy_set_header X-NginX-Proxy true;
}
location /assets { # Serving your statics with NginX is good practice
alias /path/to/subway/assets/;
}
} Subway's config.js dev: {
port: process.env.PORT || 3000,
// This is to make sure the client does not try to connect to port 3000
client_port: process.env.CLIENT_PORT || process.env.PORT || 443
},
prod: {
port: process.env.PORT || 3000,
// And again
client_port: 443
}, |
yep, that worked !! thx |
Yeah, I tried that too, but have found no way to let node.js know it's in a folder, which breaks all static files. @ericbarch: Do you think the NginX as a reverse proxy solution is sufficient to close this issue? |
Ow, and there seems to be someone that has implemented this in subway itself: https://github.com/pdxcat/subway/commit/a90c58b94a2bc040890b97d957f75e6cffe7d3cc |
yeah its only 5 more lines of code, i did it yesterday too, but i still prefer the nginx fronted. |
Add configuration options for SSL cert or generate a self signed cert for securing the connection. Some cellular networks and proxies break non-secure websockets, so this could help improve performance in those situations.
The text was updated successfully, but these errors were encountered: