Docker with traefik -- no log error -- page 404

Hello. So I took a good look at the other relating threads on this but the suggestions & solutions haven’t worked-out with this specific setup. I should warn, I have little understanding of what i’m doing.

I have docker on ubuntu server 2.04 with traefik & portainer running fine. I played with n8n desktop & thought I set it up over to this same server in hopes of not having to deal with nginx.

/home/user/ is where all the files are saved. Thinking of using /home/user/n8n/data/.n8n to hold the config, database etc.

/n8n has the following docker-compose.yml
I did make variations with different labels, environments, & volumes but this one is the last tried copy.


Summary

version: “3”
services:
n8n:
image: n8nio/n8n
restart: always
ports:
- “127.0.0.1:5678:5678”
labels:
- traefik.enable=true
- traefik.http.routers.n8n.rule=Host(${SUBDOMAIN}.${DOMAIN_NAME})
- traefik.http.routers.n8n.tls=true
- traefik.http.routers.n8n.entrypoints=web,websecure
- traefik.http.routers.n8n.tls.certresolver=mytlschallenge
- traefik.http.middlewares.n8n.headers.SSLRedirect=true
- traefik.http.middlewares.n8n.headers.STSSeconds=315360000
- traefik.http.middlewares.n8n.headers.browserXSSFilter=true
- traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
- traefik.http.middlewares.n8n.headers.forceSTSHeader=true
- traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
- traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
- traefik.http.middlewares.n8n.headers.STSPreload=true
- [email protected]
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER
- N8N_BASIC_AUTH_PASSWORD
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- N8N_LOG_LEVEL=debug
volumes:
- ${DATA_FOLDER}/.n8n:/home/user/data/.n8n
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock


The .env file:

I did try a few versions with different directories for the data_folder but userSettings defaults to /home/node/.n8n/config

Summary

Folder where data should be saved

DATA_FOLDER=/home/user/n8n/data/

The top level domain to serve from

DOMAIN_NAME=domain.io

The subfolder to serve from

SUBFOLDER=n8n

N8N_PATH=/n8n/

The subdomain to serve from

SUBDOMAIN=n8n

DOMAIN_NAME and SUBDOMAIN combined decide where n8n will be reachable from

above example would result in: https://example.com/n8n/

The user name to use for autentication - IMPORTANT ALWAYS CHANGE!

N8N_BASIC_AUTH_USER=user

The password to use for autentication - IMPORTANT ALWAYS CHANGE!

N8N_BASIC_AUTH_PASSWORD=pass

Optional timezone to set which gets used by Cron-Node by default

If not set New York time will be used

GENERIC_TIMEZONE=Somewhere/Nice

The email address to use for the SSL certificate creation

[email protected]


This is the log:

Summary

[+] Running 1/1
⠿ Container n8n-n8n-1 Created 0.1s
Attaching to n8n-n8n-1
n8n-n8n-1 | 2022-08-04T01:57:08.643Z | info | Initializing n8n process “{ file: ‘start.js’ }”
n8n-n8n-1 | UserSettings were generated and saved to: /home/node/.n8n/config
n8n-n8n-1 | 2022-08-04T01:57:11.566Z | debug | No codex available for: N8nTrainingCustomerDatastore.node.js “{ file: ‘LoadNodesAndCredentials.js’, function: ‘addCodex’ }”
n8n-n8n-1 | 2022-08-04T01:57:11.568Z | debug | No codex available for: N8nTrainingCustomerMessenger.node.js “{ file: ‘LoadNodesAndCredentials.js’, function: ‘addCodex’ }”
n8n-n8n-1 | query is slow: CREATE TABLE “migrations” (“id” integer PRIMARY KEY AUTOINCREMENT NOT NULL, “timestamp” bigint NOT NULL, “name” varchar NOT NULL)
n8n-n8n-1 | execution time: 4802
n8n-n8n-1 | 2022-08-04T01:57:13.635Z | warn | Migrations in progress, please do NOT stop the process. “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.636Z | debug | Starting migration InitialMigration1588102412422 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.765Z | debug | Finished migration InitialMigration1588102412422 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.802Z | debug | Starting migration WebhookModel1592445003908 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.826Z | debug | Finished migration WebhookModel1592445003908 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.853Z | debug | Starting migration CreateIndexStoppedAt1594825041918 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.881Z | debug | Finished migration CreateIndexStoppedAt1594825041918 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.908Z | debug | Starting migration MakeStoppedAtNullable1607431743769 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.939Z | debug | Finished migration MakeStoppedAtNullable1607431743769 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:13.977Z | debug | Starting migration AddWebhookId1611071044839 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:14.092Z | debug | Finished migration AddWebhookId1611071044839 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:14.128Z | debug | Starting migration CreateTagEntity1617213344594 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:14.693Z | debug | Finished migration CreateTagEntity1617213344594 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:14.721Z | debug | Starting migration UniqueWorkflowNames1620821879465 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:14.749Z | debug | Finished migration UniqueWorkflowNames1620821879465 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:14.777Z | debug | Starting migration AddWaitColumn1621707690587 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:14.975Z | debug | Finished migration AddWaitColumn1621707690587 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.014Z | debug | Starting migration UpdateWorkflowCredentials1630330987096 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.022Z | debug | Finished migration UpdateWorkflowCredentials1630330987096 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.057Z | debug | Starting migration AddExecutionEntityIndexes1644421939510 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.230Z | debug | Finished migration AddExecutionEntityIndexes1644421939510 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.265Z | debug | Starting migration CreateUserManagement1646992772331 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.682Z | debug | Finished migration CreateUserManagement1646992772331 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.711Z | debug | Starting migration LowerCaseUserEmail1648740597343 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.736Z | debug | Finished migration LowerCaseUserEmail1648740597343 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.765Z | debug | Starting migration CommunityNodes1652254514001 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.825Z | debug | Finished migration CommunityNodes1652254514001 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:15.852Z | debug | Starting migration AddUserSettings1652367743993 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.000Z | debug | Finished migration AddUserSettings1652367743993 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.030Z | debug | Starting migration AddAPIKeyColumn1652905585850 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.199Z | debug | Finished migration AddAPIKeyColumn1652905585850 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.227Z | debug | Starting migration IntroducePinData1654089251344 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.255Z | debug | Finished migration IntroducePinData1654089251344 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.313Z | debug | Starting migration AddNodeIds1658930531669 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.317Z | debug | Finished migration AddNodeIds1658930531669 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.420Z | warn | Migrations finished. “{ file: ‘migrationHelpers.js’ }”
n8n-n8n-1 | 2022-08-04T01:57:16.445Z | debug | Wait tracker querying database for waiting executions “{ file: ‘WaitTracker.js’, function: ‘getwaitingExecutions’ }”
n8n-n8n-1 | n8n ready on 0.0.0.0, port 5678
n8n-n8n-1 | Version: 0.189.0
n8n-n8n-1 | 2022-08-04T01:57:16.536Z [Rudder] debug: in flush
n8n-n8n-1 | 2022-08-04T01:57:16.537Z [Rudder] debug: batch size is 1
n8n-n8n-1 | 2022-08-04T01:57:16.541Z [Rudder] debug: no existing flush timer, creating new one
n8n-n8n-1 |
n8n-n8n-1 | Editor is now accessible via:
n8n-n8n-1 | https://sub.domain.io:5678/


I did try sub-sub folder for the domain and got the certificate working but it still hits page 404.

Not sure where to go from here.

All inputs are much appreciated.

Hi @jay, sorry to hear you’re having trouble! Is the 404 error coming from traefik?

I am asking because your docker compose file doesn’t seem to expose ports 80 (HTTP) and 443 (HTTPS) from traefik, so my first guess would be another web server than traefik answering your browser’s request (and not knowing what to do with it).

Hi there. Appreciate the quick response.

I updated the docker-compose.yml by commenting out the default port, adding loadbalancer for 443 & 80. This time, the favicon shows up on the tab and page indicates “gateway timeout”. So its getting somewhere.

I gave sub sub domain another try with the above changes so that it could work with ssl from traefik, but the ${SUB_SUBDOMAIN}.${SUBDOMAIN}.${DOMAIN_NAME} goes to page 404. env was also changed according to these variations.


Summary

version: “3”
services:
n8n:
image: n8nio/n8n
restart: always
labels:
- “traefik.enable=true”
- “traefik.http.services.n8n.loadbalancer.server.port=443”
- “traefik.http.services.n8n.loadbalancer.server.port=80”
- “traefik.http.routers.n8n.rule=Host(${SUBDOMAIN}.${DOMAIN_NAME})”
- “traefik.http.routers.n8n.tls=true”
- “traefik.http.middlewares.n8n.headers.SSLRedirect=true”
- “traefik.http.middlewares.n8n.headers.STSSeconds=315360000”
- “traefik.http.middlewares.n8n.headers.browserXSSFilter=true”
- “traefik.http.middlewares.n8n.headers.contentTypeNosniff=true”
- “traefik.http.middlewares.n8n.headers.forceSTSHeader=true”
- “traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}”
- “traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true”
- “traefik.http.middlewares.n8n.headers.STSPreload=true”
- “[email protected]
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER
- N8N_BASIC_AUTH_PASSWORD
- N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
# N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- N8N_LOG_LEVEL=debug
volumes:
- ${DATA_FOLDER}/.n8n:/home/user/data/.n8n
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock


When looking at the log, it still seems to default to port 5678 and the same userSettings directory. How can one force those changes?

The log now:


Summary

2022-08-04T15:23:51.534086149Z 2022-08-04T15:23:51.533Z | debug | Finished migration UniqueWorkflowNames1620821879465 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:51.563538768Z 2022-08-04T15:23:51.562Z | debug | Starting migration AddWaitColumn1621707690587 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:51.782881715Z 2022-08-04T15:23:51.782Z | debug | Finished migration AddWaitColumn1621707690587 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:51.811881103Z 2022-08-04T15:23:51.811Z | debug | Starting migration UpdateWorkflowCredentials1630330987096 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:51.818337063Z 2022-08-04T15:23:51.817Z | debug | Finished migration UpdateWorkflowCredentials1630330987096 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:51.847289062Z 2022-08-04T15:23:51.846Z | debug | Starting migration AddExecutionEntityIndexes1644421939510 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:52.002443789Z 2022-08-04T15:23:52.001Z | debug | Finished migration AddExecutionEntityIndexes1644421939510 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:52.029280705Z 2022-08-04T15:23:52.028Z | debug | Starting migration CreateUserManagement1646992772331 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:52.440869160Z 2022-08-04T15:23:52.440Z | debug | Finished migration CreateUserManagement1646992772331 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:52.469814228Z 2022-08-04T15:23:52.469Z | debug | Starting migration LowerCaseUserEmail1648740597343 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:52.500502394Z 2022-08-04T15:23:52.499Z | debug | Finished migration LowerCaseUserEmail1648740597343 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:52.526631947Z 2022-08-04T15:23:52.525Z | debug | Starting migration CommunityNodes1652254514001 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:52.589648332Z 2022-08-04T15:23:52.588Z | debug | Finished migration CommunityNodes1652254514001 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:52.616895131Z 2022-08-04T15:23:52.616Z | debug | Starting migration AddUserSettings1652367743993 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:52.770330803Z 2022-08-04T15:23:52.769Z | debug | Finished migration AddUserSettings1652367743993 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:52.805486311Z 2022-08-04T15:23:52.804Z | debug | Starting migration AddAPIKeyColumn1652905585850 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:52.992921246Z 2022-08-04T15:23:52.992Z | debug | Finished migration AddAPIKeyColumn1652905585850 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:53.019666704Z 2022-08-04T15:23:53.018Z | debug | Starting migration IntroducePinData1654089251344 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:53.052405412Z 2022-08-04T15:23:53.051Z | debug | Finished migration IntroducePinData1654089251344 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:53.086954671Z 2022-08-04T15:23:53.086Z | debug | Starting migration AddNodeIds1658930531669 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationStart’ }”
2022-08-04T15:23:53.091738303Z 2022-08-04T15:23:53.090Z | debug | Finished migration AddNodeIds1658930531669 “{ file: ‘migrationHelpers.js’, function: ‘logMigrationEnd’ }”
2022-08-04T15:23:53.200174665Z 2022-08-04T15:23:53.199Z | warn | Migrations finished. “{ file: ‘migrationHelpers.js’ }”
2022-08-04T15:23:53.235437122Z 2022-08-04T15:23:53.229Z | debug | Wait tracker querying database for waiting executions “{ file: ‘WaitTracker.js’, function: ‘getwaitingExecutions’ }”
2022-08-04T15:23:53.316550661Z n8n ready on 0.0.0.0, port 5678
2022-08-04T15:23:53.316606408Z Version: 0.189.0
2022-08-04T15:23:53.327468710Z 2022-08-04T15:23:53.326Z [Rudder] debug: in flush
2022-08-04T15:23:53.327700789Z 2022-08-04T15:23:53.327Z [Rudder] debug: batch size is 1
2022-08-04T15:23:53.331512198Z 2022-08-04T15:23:53.331Z [Rudder] debug: no existing flush timer, creating new one
2022-08-04T15:23:53.661567022Z
2022-08-04T15:23:53.661643255Z Editor is now accessible via:
2022-08-04T15:23:53.661660095Z https://sub.main.io:5678/


Edit: sorry to clarify, there’s no other server using such ports.

After having another go at this, i figured out that I had the whole port situation upside down.

Left the default 5678 port on the loadbalancer, added the same network name used by traefik & it worked.

The docker-compose file with sub-sub domain(redacted):


Summary

version: “3”

services:
n8n:
image: n8nio/n8n:latest
container_name: n8n1
labels:
- “traefik.enable=true”
- “traefik.http.services.n8n.loadbalancer.server.port=5678”
- “traefik.http.routers.n8n.rule=Host(${SUB_SUBDOMAIN}.${SUBDOMAIN}.${DOMAIN_NAME})”
- “traefik.http.routers.n8n.tls=true”
- “traefik.http.middlewares.n8n.headers.SSLRedirect=true”
- “traefik.http.middlewares.n8n.headers.STSSeconds=315360000”
- “traefik.http.middlewares.n8n.headers.browserXSSFilter=true”
- “traefik.http.middlewares.n8n.headers.contentTypeNosniff=true”
- “traefik.http.middlewares.n8n.headers.forceSTSHeader=true”
- “traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}”
- “traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true”
- “traefik.http.middlewares.n8n.headers.STSPreload=true”
- “[email protected]
environment:
- N8N_BASIC_AUTH_ACTIVE=true
- N8N_BASIC_AUTH_USER
- N8N_BASIC_AUTH_PASSWORD
- N8N_HOST=${SUB_SUBDOMAIN}.${SUBDOMAIN}.${DOMAIN_NAME}
- N8N_PORT=5678
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_URL=https://${SUB_SUBDOMAIN}.${SUBDOMAIN}.${DOMAIN_NAME}/
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
- N8N_LOG_LEVEL=debug
networks:
- proxy
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock
- ${DATA_FOLDER}/.n8n:/home/user/n8n/data/.n8n
- /home/user/n8n/data/.n8n/local-files:/files
networks:
proxy:
external: true


The .env file (redacted):

Summary

DATA_FOLDER=/home/user/n8n/data/

DOMAIN_NAME=domain.io

SUBDOMAIN=sub

SUB_SUBDOMAIN=subsub

// so it becomes subsub.sub.domain.io

N8N_BASIC_AUTH_USER=user

N8N_BASIC_AUTH_PASSWORD=pass

GENERIC_TIMEZONE=Somewhere/Nice

[email protected]


Hi @jay, it looks like your updated docker compose file still doesn’t expose 80s and 443 to your host. So when a request on these ports reaches your server traefik can’t respond to these. If you check the example file from Docker Compose - n8n Documentation you can see the section exposing these ports:

    ports:
      - "80:80"
      - "443:443"