mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 11:49:59 +00:00
Add HTTPS support by giving an SSL Cert and Key
This commit is contained in:
@@ -97,6 +97,10 @@ class App {
|
||||
push: Push.Push;
|
||||
versions: IPackageVersions | undefined;
|
||||
|
||||
protocol: string;
|
||||
ssl_key: string;
|
||||
ssl_cert: string;
|
||||
|
||||
constructor() {
|
||||
this.app = express();
|
||||
|
||||
@@ -112,6 +116,10 @@ class App {
|
||||
this.push = Push.getInstance();
|
||||
|
||||
this.activeExecutionsInstance = ActiveExecutions.getInstance();
|
||||
|
||||
this.protocol = config.get('protocol');
|
||||
this.ssl_key = config.get('ssl_key');
|
||||
this.ssl_cert = config.get('ssl_cert');
|
||||
}
|
||||
|
||||
|
||||
@@ -1254,8 +1262,23 @@ export async function start(): Promise<void> {
|
||||
const app = new App();
|
||||
|
||||
await app.config();
|
||||
|
||||
// Differntiate HTTP and HTTPS server
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
var server;
|
||||
|
||||
app.app.listen(PORT, async () => {
|
||||
if(app.protocol === 'https'){
|
||||
const privateKey = fs.readFileSync(app.ssl_key,'utf8');
|
||||
const cert = fs.readFileSync(app.ssl_cert,'utf8');
|
||||
const credentials = {key: privateKey,cert: cert};
|
||||
server = https.createServer(credentials,app.app);
|
||||
}else{
|
||||
server = http.createServer(app.app);
|
||||
}
|
||||
|
||||
server.listen(PORT, async () => {
|
||||
const versions = await GenericHelpers.getVersions();
|
||||
console.log(`n8n ready on port ${PORT}`);
|
||||
console.log(`Version: ${versions.cli}`);
|
||||
|
||||
Reference in New Issue
Block a user