0

I want to run node.js and socket.io on the https. I redirect requests which are coming from server.example.com to http://example.com:3000

<VirtualHost server.example.com:80>
    ProxyPass / http://example.com:3000/
</VirtualHost>

And this way i can access to socket.io.js file

https://server.example.com/socket.io/socket.io.js

To test node.js part, print socket.id in console.

Image : http://prntscr.com/jq81bz

Here is the client side, i connect to socket.io with this way.

Image : http://prntscr.com/jq830z

The client connects node.js server and print the socket.id. But there are many errors occurred in browser console. I think the client wants to connect again because of errors.

Image : http://prntscr.com/jq82ib <- server's console is on left

Those logs printed for just one connection.

1 Answer 1

0

You apache configurations must be changed as follow.

<VirtualHost *:443>
     ServerName mysite.com
     ServerAlias www.mysite.com

     SSLEngine on
     SSLProxyEngine On
     ProxyRequests Off

     SSLCertificateFile /etc/apache2/ssl/mysite.com.crt
     SSLCertificateKeyFile /etc/apache2/ssl/mysite.com.key
     SSLCertificateChainFile /etc/apache2/ssl/ca.cer

     DocumentRoot /var/www/errorPages

     ErrorDocument 503 /503.html
     ProxyPass /503.html !

     ProxyPass / http://localhost:3000/
     ProxyPassReverse / http://localhost:3000/


     RewriteEngine on
     RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
     RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
     RewriteRule .* ws://localhost:3000%{REQUEST_URI} [P]


</VirtualHost>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.