Make server listen address configurable (#618)

This commit is contained in:
Patrick Wellever
2020-06-04 03:36:10 -04:00
committed by GitHub
parent 35c149c7b1
commit 49ea7e2739
4 changed files with 13 additions and 2 deletions

View File

@@ -14,6 +14,9 @@ Sets how n8n should be made available.
# The port n8n should be made available on # The port n8n should be made available on
N8N_PORT=5678 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. # 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 # 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 # encouraged to set them correctly anyway in case they will become

View File

@@ -105,6 +105,7 @@ services:
- N8N_BASIC_AUTH_PASSWORD - N8N_BASIC_AUTH_PASSWORD
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME} - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678 - N8N_PORT=5678
- N8N_LISTEN_ADDRESS=0.0.0.0
- N8N_PROTOCOL=https - N8N_PROTOCOL=https
- NODE_ENV=production - NODE_ENV=production
- WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/ - WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/

View File

@@ -169,6 +169,12 @@ const config = convict({
env: 'N8N_PORT', env: 'N8N_PORT',
doc: 'HTTP port n8n can be reached' 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: { protocol: {
format: ['http', 'https'], format: ['http', 'https'],
default: 'http', default: 'http',

View File

@@ -1294,6 +1294,7 @@ class App {
export async function start(): Promise<void> { export async function start(): Promise<void> {
const PORT = config.get('port'); const PORT = config.get('port');
const ADDRESS = config.get('listen_address');
const app = new App(); const app = new App();
@@ -1312,9 +1313,9 @@ export async function start(): Promise<void> {
server = http.createServer(app.app); server = http.createServer(app.app);
} }
server.listen(PORT, async () => { server.listen(PORT, ADDRESS, async () => {
const versions = await GenericHelpers.getVersions(); 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}`); console.log(`Version: ${versions.cli}`);
}); });
} }