I am trying to run NodeJS behind Apache and so far I am stuck with Socket.io issue.
I have no issue accessing the application directly, but whenever I accessed through my domain, I get this error thrown from socket.io:
Firefox can’t establish a connection to the server at wss://example.com/socket.io/?EIO=3&transport=websocket&sid=X-hLU73t7ojk2zoRAAAB.
My Apache configuration is as follows:
<VirtualHost _default_:443>
ServerName example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
ProxyRequests off
ProxyVia on
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:8080/$1 [P,L]
ProxyPass /socket.io http://localhost:8080/socket.io
ProxyPassReverse /socket.io http://localhost:8080/socket.io
<Location />
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse http://127.0.0.1:8080/
</Location>
#ProxyPass / http://localhost:8080/
#ProxyPassReverse / http://localhost:8080/
# BrowserMatch "MSIE [2-6]" \
# nokeepalive ssl-unclean-shutdown \
# downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</VirtualHost>
I have also tried changing the RewriteRule /(.*)
to wss://localhost:8080/$1 [P,L]
but still thrown the same error. Can't seem to find any other answer to solve this.
I believe I am using socket.io 2.0, and on the client side it is connected as such:
var socket = io();
This is what bugs me,
It seems that some of the connection is going through but one is not.