mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 21:07:28 -08:00
⚡ Minor improvements to SSL support
This commit is contained in:
parent
37ccff8cb8
commit
f00b7347c8
|
@ -137,6 +137,19 @@ export NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## SSL
|
||||||
|
|
||||||
|
It is possible to start n8n with SSL enabled by supplying a certificate to use:
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export N8N_PROTOCOL=https
|
||||||
|
export N8N_SSL_KEY=/data/certs/server.key
|
||||||
|
export N8N_SSL_CERT=/data/certs/server.pem
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Timezone
|
## Timezone
|
||||||
|
|
||||||
The timezone is set by default to "America/New_York". It gets for example used by the
|
The timezone is set by default to "America/New_York". It gets for example used by the
|
||||||
|
|
|
@ -288,10 +288,10 @@ const config = convict({
|
||||||
// Overwrite default configuration with settings which got defined in
|
// Overwrite default configuration with settings which got defined in
|
||||||
// optional configuration files
|
// optional configuration files
|
||||||
if (process.env.N8N_CONFIG_FILES !== undefined) {
|
if (process.env.N8N_CONFIG_FILES !== undefined) {
|
||||||
const configFiles = process.env.N8N_CONFIG_FILES.split(',');
|
const configFiles = process.env.N8N_CONFIG_FILES.split(',');
|
||||||
console.log(`\nLoading configuration overwrites from:\n - ${configFiles.join('\n - ')}\n`);
|
console.log(`\nLoading configuration overwrites from:\n - ${configFiles.join('\n - ')}\n`);
|
||||||
|
|
||||||
config.loadFile(configFiles);
|
config.loadFile(configFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
config.validate({
|
config.validate({
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
|
import {
|
||||||
|
readFileSync,
|
||||||
|
} from 'fs';
|
||||||
import {
|
import {
|
||||||
dirname as pathDirname,
|
dirname as pathDirname,
|
||||||
join as pathJoin,
|
join as pathJoin,
|
||||||
|
@ -98,8 +101,8 @@ class App {
|
||||||
versions: IPackageVersions | undefined;
|
versions: IPackageVersions | undefined;
|
||||||
|
|
||||||
protocol: string;
|
protocol: string;
|
||||||
ssl_key: string;
|
sslKey: string;
|
||||||
ssl_cert: string;
|
sslCert: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.app = express();
|
this.app = express();
|
||||||
|
@ -118,8 +121,8 @@ class App {
|
||||||
this.activeExecutionsInstance = ActiveExecutions.getInstance();
|
this.activeExecutionsInstance = ActiveExecutions.getInstance();
|
||||||
|
|
||||||
this.protocol = config.get('protocol');
|
this.protocol = config.get('protocol');
|
||||||
this.ssl_key = config.get('ssl_key');
|
this.sslKey = config.get('ssl_key');
|
||||||
this.ssl_cert = config.get('ssl_cert');
|
this.sslCert = config.get('ssl_cert');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1262,19 +1265,17 @@ export async function start(): Promise<void> {
|
||||||
const app = new App();
|
const app = new App();
|
||||||
|
|
||||||
await app.config();
|
await app.config();
|
||||||
|
|
||||||
// Differntiate HTTP and HTTPS server
|
let server;
|
||||||
const http = require('http');
|
|
||||||
const https = require('https');
|
|
||||||
const fs = require('fs');
|
|
||||||
var server;
|
|
||||||
|
|
||||||
if(app.protocol === 'https'){
|
if(app.protocol === 'https'){
|
||||||
const privateKey = fs.readFileSync(app.ssl_key,'utf8');
|
const https = require('https');
|
||||||
const cert = fs.readFileSync(app.ssl_cert,'utf8');
|
const privateKey = readFileSync(app.sslKey,'utf8');
|
||||||
const credentials = {key: privateKey,cert: cert};
|
const cert = readFileSync(app.sslCert,'utf8');
|
||||||
|
const credentials = { key: privateKey,cert };
|
||||||
server = https.createServer(credentials,app.app);
|
server = https.createServer(credentials,app.app);
|
||||||
}else{
|
}else{
|
||||||
|
const http = require('http');
|
||||||
server = http.createServer(app.app);
|
server = http.createServer(app.app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue