My websocket setup works in http. But if I enable ssl(lets encrypt) and change the ws://
to wss://
, browser throws this error.
WebSocket connection to 'wss://xx.yy.xx.yy:5001/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED
Javascript:
var ws = new WebSocket('wss://xx.yy.xx.yy:5001');
I then enabled these apache modules: proxy_http
, proxy_wstunnel
, proxy_balancer
And added these lines in /etc/apache2/sites-enabled/000-default-le-ssl.conf
<IfModule mod_proxy.c>
ProxyPass / ws://xx.yy.xx.yy:5001
ProxyPassReverse / ws://xx.yy.xx.yy:5001
</IfModule>
Got a 500 Server Error.
Though I had no idea how this proxy thing works, just given a blind try. Please correct my mistake, help me to fix this. Thanks.
Server details:
- Apache 2.4.18 running in AWS EC2 ubuntu instance.
- public ip : xx.yy.xx.yy
- private ip : aa.bb.aa.bb
Websocket setup:
I use private ip for back-end(php) connection and public ip in front-end.