Fehler bei undefinertem hHost abgefangen
This commit is contained in:
parent
751d0cdb70
commit
dc76e5c7b6
18
server.js
18
server.js
@ -43,11 +43,19 @@ webserver.listen(app_cfg.global.https_port, function() {
|
|||||||
// Redirect all HTTP traffic to HTTPS
|
// Redirect all HTTP traffic to HTTPS
|
||||||
http.createServer(function(req, res) {
|
http.createServer(function(req, res) {
|
||||||
var host = req.headers.host;
|
var host = req.headers.host;
|
||||||
host = host.replace(/:\d+$/, ":" + app_cfg.global.https_port);
|
// prüfen ob host gesetzt, sonst 404
|
||||||
res.writeHead(301, {
|
if (typeof host !== 'undefined' && host) {
|
||||||
"Location": "https://" + host + req.url
|
// Anfrage auf https umleiten
|
||||||
});
|
host = host.replace(/:\d+$/, ":" + app_cfg.global.https_port);
|
||||||
res.end();
|
res.writeHead(301, {
|
||||||
|
"Location": "https://" + host + req.url
|
||||||
|
});
|
||||||
|
res.end();
|
||||||
|
} else {
|
||||||
|
// HTTP status 404: NotFound
|
||||||
|
res.status(404)
|
||||||
|
.send('Not found - use https instead!');
|
||||||
|
};
|
||||||
}).listen(app_cfg.global.http_port);
|
}).listen(app_cfg.global.http_port);
|
||||||
|
|
||||||
// TODO: auf HTTPS mit TLS1.2 umstellen, inkl. WSS
|
// TODO: auf HTTPS mit TLS1.2 umstellen, inkl. WSS
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user