What I am trying to do is to redirect an http request to https on nodejs express...
The thing is i have my https service listening on port 444, and i want to redirect an http req on the port 444 to https.
for example when i request this "https://url:444" works
when i do this "url:444" the broser put the "https://"
but when i do this "http://url:444" there is a timeout.
I been trying some http redirect to https things, but almost every clue i found it's two services one listening on port 80 (http) and the 443 (https) but that does not work in my case.
I run my server like this.
var app = require('express')()
, https = require('https')
PORT = process.env.PORT || 443;
var privateKey = fs.readFileSync('../keys/server.key', 'utf8')
, certificate = fs.readFileSync('../keys/server.crt', 'utf8')
, credentials = { key : privateKey, cert : certificate }
, httpsServer = https.createServer(credentials, app);
httpsServer.listen(PORT, function(){
'use strict';
console.log('Listen on port ' + PORT);
});