From 49ea7e27390a1f96ee4ffddabfeb070cd7008692 Mon Sep 17 00:00:00 2001 From: Patrick Wellever <239789+pwellever@users.noreply.github.com> Date: Thu, 4 Jun 2020 03:36:10 -0400 Subject: [PATCH] :sparkles: Make server listen address configurable (#618) --- docs/configuration.md | 3 +++ docs/server-setup.md | 1 + packages/cli/config/index.ts | 6 ++++++ packages/cli/src/Server.ts | 5 +++-- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index ce57ef92df..63b8c95f12 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -14,6 +14,9 @@ Sets how n8n should be made available. # The port n8n should be made available on N8N_PORT=5678 +# The IP address n8n should listen on +N8N_LISTEN_ADDRESS=0.0.0.0 + # This ones are currently only important for the webhook URL creation. # So if "WEBHOOK_TUNNEL_URL" got set they do get ignored. It is however # encouraged to set them correctly anyway in case they will become diff --git a/docs/server-setup.md b/docs/server-setup.md index f2c830c48f..d34d076a6f 100644 --- a/docs/server-setup.md +++ b/docs/server-setup.md @@ -105,6 +105,7 @@ services: - N8N_BASIC_AUTH_PASSWORD - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME} - N8N_PORT=5678 + - N8N_LISTEN_ADDRESS=0.0.0.0 - N8N_PROTOCOL=https - NODE_ENV=production - WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/ diff --git a/packages/cli/config/index.ts b/packages/cli/config/index.ts index 69b3154064..a8b1886277 100644 --- a/packages/cli/config/index.ts +++ b/packages/cli/config/index.ts @@ -169,6 +169,12 @@ const config = convict({ env: 'N8N_PORT', doc: 'HTTP port n8n can be reached' }, + listen_address: { + format: String, + default: '0.0.0.0', + env: 'N8N_LISTEN_ADDRESS', + doc: 'IP address n8n should listen on' + }, protocol: { format: ['http', 'https'], default: 'http', diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 02b4afb29e..a5beea41e2 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -1294,6 +1294,7 @@ class App { export async function start(): Promise { const PORT = config.get('port'); + const ADDRESS = config.get('listen_address'); const app = new App(); @@ -1312,9 +1313,9 @@ export async function start(): Promise { server = http.createServer(app.app); } - server.listen(PORT, async () => { + server.listen(PORT, ADDRESS, async () => { const versions = await GenericHelpers.getVersions(); - console.log(`n8n ready on port ${PORT}`); + console.log(`n8n ready on ${ADDRESS}, port ${PORT}`); console.log(`Version: ${versions.cli}`); }); }