express-ws icon indicating copy to clipboard operation
express-ws copied to clipboard

Usage behind a apache/nginx reverse proxy

Open tzvc opened this issue 6 years ago • 1 comments

Hi there,

I'm trying to use express-ws on my application sitting behind a Apache2 reverse proxy but I can't get it to work, I keep getting

WebSocketException: Connection to 'https://blablamyapi.net/ws' was not upgraded to websocket

Thing is everything works properly on local so I suspect that the problem is the reverse proxy on my remote server is not letting the websocket upgrade requests through properly. I tried a few solution found online for my apache config:

<IfModule mod_ssl.c>
<VirtualHost *:443>
	ServerName blablamyapi.te
	ServerAlias blablamyapi.te

	ProxyPreserveHost On

	RewriteEngine on
	RewriteCond %{HTTP:Upgrade} websocket [NC]
	RewriteCond %{HTTP:Connection} upgrade [NC]
	RewriteRule .* "wss://0.0.0.0:3030%{REQUEST_URI}" [P]

	ProxyPass / http://0.0.0.0:3030/
	ProxyPassReverse / http://0.0.0.0:3030/

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined




</VirtualHost>
</IfModule>

Have anyone manage to do this before? What am I missing here?

tzvc avatar Dec 10 '19 23:12 tzvc

does your apache server support websocket tunneling? A quick google search came up with https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html

taxilian avatar May 10 '20 15:05 taxilian