diff --git a/docs/configuration.md b/docs/configuration.md index 503e90b075..b0fca4dbc2 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -177,3 +177,52 @@ webhook URLs get registred with external services. ```bash export WEBHOOK_TUNNEL_URL="https://n8n.example.com/" ``` + + +## Configuration via file + +It is also possible to configure n8n via a configuration file. + +It is not necessary to define all values. Only the ones which should be +different from the defaults. + +If needed also multiple files can be supplied to for example have generic +base settings and some specific ones depending on the environment. + +The path to the JSON configuration file to use can be set via the environment +variable `N8N_CONFIG_FILES`. + +```bash +# Single file +export N8N_CONFIG_FILES=/folder/my-config.json + +# Multiple files can be comma-separated +export N8N_CONFIG_FILES=/folder/my-config.json,/folder/production.json +``` + +A possible configuration file could look like this: +```json +{ + "executions": { + "process": "main", + "saveDataOnSuccess": "none" + }, + "generic": { + "timezone": "Europe/Berlin" + }, + "security": { + "basicAuth": { + "active": true, + "user": "frank", + "password": "some-secure-password" + } + }, + "nodes": { + "exclude": "[\"n8n-nodes-base.executeCommand\",\"n8n-nodes-base.writeBinaryFile\"]" + } +} +``` + +All possible values which can be set and their defaults can be found here: + +[https://github.com/n8n-io/n8n/blob/master/packages/cli/config/index.ts](https://github.com/n8n-io/n8n/blob/master/packages/cli/config/index.ts) diff --git a/packages/cli/config/index.ts b/packages/cli/config/index.ts index 6405620e07..0609bdae31 100644 --- a/packages/cli/config/index.ts +++ b/packages/cli/config/index.ts @@ -273,6 +273,15 @@ const config = convict({ }); +// Overwrite default configuration with settings which got defined in +// optional configuration files +if (process.env.N8N_CONFIG_FILES !== undefined) { + const configFiles = process.env.N8N_CONFIG_FILES.split(','); + console.log(`\nLoading configuration overwrites from:\n - ${configFiles.join('\n - ')}\n`); + + config.loadFile(configFiles); +} + config.validate({ allowed: 'strict', });