I need to switch from HTTP to HTTPS to be able to use the getUsermedia for webrtc implementation. I've installed certificates on my Apache version 2.2.22 and got it working.
In the website I'm hosting NodeJS is used. Perhaps not the ideal setup but I've encountered problems when socket.io on the client wants to communicate with the NodeJS server.
In the console this message appears:
GET https://mydomain.nl:1900/socket.io/?EIO=3&transport=polling&t=1449219985177-166 net::ERR_CONNECTION_CLOSED 
It's obvious to me that the NodeJS server app can't handle requests over HTTPS because it's an HTTP server.
I want to alter that server to be able to serve HTTPS requests using the SSL already in place on the apache webserver.
Is this possible at all?
The benefits Apache brings to Node. js applications. How to configure Apache for a Node.
The Apache HTTP Server module mod_ssl provides an interface to the OpenSSL library, which provides Strong Encryption using the Secure Sockets Layer and Transport Layer Security protocols.
If you're prepared to re-write your PHP in JavaScript, then yes, Node. js can replace your Apache. If you place an Apache or NGINX instance running in reverse-proxy mode between your servers and your clients, you could handle some requests in JavaScript on Node.
I recommend to have a look apache's mod_proxy. This would allow you to run the external requests over the apache SSL pipeline. The node.js can run only on the localhost interface without ssl support because it's proxy'd by apache. I you configure a vhost it could look like this:
<VirtualHost *:443>
  ServerName www.yourserver.com
  DocumentRoot /var/www/vhosts/www.yourserver.com/public_html
  CustomLog <LOG-PATH> combined
  ErrorLog <ERROR-LOG-PATH>
  # Example SSL configuration
  SSLEngine on
  SSLProtocol all -SSLv2
  SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
  SSLCertificateFile "<CERT-PATH>/server.crt"
  SSLCertificateKeyFile "<CERT-PATH>/server.key"
  ProxyPass /<PATH>/ http://localhost:1900/
  ProxyPassReverse /<PATH>/ http://myserver:1900/
</VirtualHost>
Your reguest would then look like this:
GET https://mydomain.nl/<PATH>/?.... 
Where <PATH> has the same value as in the vhost config's <ProxyPass> directive. 
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With