Adding option for http to redirect to https
This commit is contained in:
parent
5e6358602e
commit
95050849d8
|
@ -2,6 +2,7 @@
|
|||
"http": true,
|
||||
"http_host": "0.0.0.0",
|
||||
"http_port": 7777,
|
||||
"http_redirect_to_https": false,
|
||||
|
||||
"https": false,
|
||||
"https_host": "0.0.0.0",
|
||||
|
|
11
server.js
11
server.js
|
@ -186,15 +186,20 @@ app.use(connect_st({
|
|||
index: 'index.html'
|
||||
}));
|
||||
|
||||
|
||||
if (config.http) {
|
||||
if (config.http && config.https && config.http_redirect_to_https){
|
||||
http.createServer(function(req, res) {
|
||||
res.writeHead(301, { "Location": "https:\/\/" + req.headers['host'] + req.url });
|
||||
res.end();
|
||||
}).listen(config.http_port, config.http_host)
|
||||
winston.info('redirecting http traffic to https');
|
||||
} else {
|
||||
http.createServer(app).listen(config.http_port, config.http_host);
|
||||
winston.info('listening on http:\/\/' + config.http_host + ':' + config.http_port);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.https) {
|
||||
https.createServer(https_options, app).listen(config.https_port, config.https_host);
|
||||
winston.info('listening on https:\/\/' + config.https_host + ':' + config.https_port);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue