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
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.
Solved it by creating a seperate Vhost as proxy for the Node js. Named it socket.mydomain.nl and everything works well
proxy nodejs
var proxy = require('http-proxy').createProxyServer();
var fs = require('fs');
express = require('express.io');
app = express();
var SSloptions = {
key: fs.readFileSync('/var/www/node/certificados/mig.xxx.key'),
cert: fs.readFileSync('/var/www/node/certificados/xxx.crt'),
ca: [
fs.readFileSync('/var/www/node/certificados/gd_bundle-xx.crt')
],
rejectUnauthorized: false,
requestCert: true,
agent: false,
strictSSL: false
};
app.https(SSloptions).io();
app.all('*', function(req, res){
proxy.web(req, res, {
target: 'http://localhost:4443',
});
});
app.listen(14443);