Hi all,
Challenge
I have a self-hosted (on VPS) n8n running smoothly behind Traefik. Everything seems to work as intended, except for using the n8n nodes with API key. Just the node should give response, since the credentials give me ‘success’.
Error message is a (404)
Request failed with status code 404. I can add the stack trace, but that
Context
So when i researched, I came across some possible issues, first was to check the .env file of the n8n instance, and the docker compose.
.env variables from n8n instance;
N8N_PUBLIC_API_BASE_URL=https://${N8N_FQDN} (which lead to the right URL)
N8N_PUBLIC_API_ENDPOINT=/api/v1
traefik conf. in docker compose
- traefik.http.routers.n8n.middlewares=secure-headers,n8n-headers,n8n-cors
traefik labels in n8n instance:
labels:
- traefik.enable=true
- traefik.http.routers.n8n.rule=Host(`${N8N_FQDN}`)
- traefik.http.routers.n8n.entrypoints=websecure
- traefik.http.routers.n8n.tls=true
- traefik.http.routers.n8n.tls.certresolver=myresolver
- traefik.http.middlewares.n8n-cors.headers.accesscontrolallowmethods=GET,POST,PUT,DELETE,OPTIONS
- traefik.http.middlewares.n8n-cors.headers.accesscontrolalloworiginlist=*
- traefik.http.middlewares.n8n-cors.headers.accesscontrolallowheaders=Accept,Authorization,Content-Type,X-N8N-API-KEY
- traefik.http.middlewares.n8n-cors.headers.accesscontrolmaxage=600
- traefik.http.middlewares.n8n-cors.headers.addvaryheader=true
# Combine both middlewares into one comma-separated list
- traefik.http.routers.n8n.middlewares=secure-headers,n8n-headers,n8n-cors
# Define custom request headers middleware
- traefik.http.middlewares.n8n-headers.headers.customrequestheaders.X-Forwarded-Proto=https
# Pass port to Traefik
- traefik.http.services.n8n.loadbalancer.server.port=${N8N_PORT}
I’m probably missing something in the accessibility from the n8n instance, towards traefik, towards the browser. But I can’t figure it out. There is more config of traefik, but that would become a bit unclear for this post.
Maybe one of you has experience with the bare minimum (but working) configuration of traefik and n8n, so I can revert it back to a leaner setup for starters.
Thanks already. Have a great weekend for now.
Cheers, Merijn