Всем привет! Помогите осуществить редирект с http на https Node.JS, по мануалам что -то не выходит, предоставляю конфиг приложения
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var app_1 = require("./app");
var http = require('http');
var https = require('https');
/*Start SSL*/
var fs = require('fs');
var httpProxy = require('http-proxy');
var privateKey = fs.readFileSync('/var/www/httpd-
cert/voishunter/cer.key').toString();
var certificate = fs.readFileSync('/var/www/httpd-
cert/voishunter/cer.crt').toString();
var chainCertificate = fs.readFileSync('/var/www/httpd-
cert/voishunter/cer.ca').toString();
httpProxy.createServer({
target: {
host: 'localhost',
port: 3000
},
ssl: {
key: privateKey,
cert: certificate,
ca: chainCertificate
}
}).listen(4000);
/*End SSL*/
var Server = /** @class */ (function () {
function Server() {
this.port = this.normalizePort(process.env.PORT || '3000');
app_1.app.set('port', this.port);
this.server = http.createServer(app_1.app);
this.server.listen(this.port);
this.server.on('error', this.onError);
}
Server.prototype.normalizePort = function (val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
};
Server.prototype.onError = function (error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof this.port === 'string'
? 'Pipe ' + this.port
: 'Port ' + this.port;
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
};
return Server;
}());
var kek = new Server();