OAuth callback URL generated with port 5678 despite reverse proxy & env vars (n8n 1.101.2, Docker + Traefik)

#17353

Issue Details

about 2 months ago
No assignee
in linearclosed:support-issue
RedowintowinRedowintowin
opened about 2 months ago
Author

Problem Description Hi, I’m running n8n (v1.101.2) in Docker behind Traefik (reverse proxy, 80/443 only, no port 5678 exposed publicly). Despite following all recommended configuration and setting the environment variables:

N8N_HOST=n8n.srv828430.hstgr.cloud

N8N_PROTOCOL=https

N8N_WEBHOOK_URL=https://n8n.srv828430.hstgr.cloud

WEBHOOK_TUNNEL_URL=https://n8n.srv828430.hstgr.cloud

N8N_TUNNEL_URL=https://n8n.srv828430.hstgr.cloud

n8n still generates the OAuth callback URL with port :5678 :

bash

https://n8n.srv828430.hstgr.cloud:5678/rest/oauth2-credential/callback But only port 443 is publicly accessible (Traefik forwards to 5678 internally).

Already tried:

Full stack restart (docker compose down && up -d)

Recreated OAuth credentials from scratch

Cleared browser cache / tried multiple browsers

Checked container env vars (see below)

Version: n8n 1.101.2 (latest stable)

Environment variables in container:

makefile

N8N_HOST=n8n.srv828430.hstgr.cloud N8N_PROTOCOL=https WEBHOOK_TUNNEL_URL=https://n8n.srv828430.hstgr.cloud N8N_WEBHOOK_URL=https://n8n.srv828430.hstgr.cloud N8N_TUNNEL_URL=https://n8n.srv828430.hstgr.cloud ... Docker Compose excerpt:

yaml

n8n: image: n8nio/n8n:latest environment: - N8N_HOST=n8n.srv828430.hstgr.cloud - N8N_PROTOCOL=https - N8N_WEBHOOK_URL=https://n8n.srv828430.hstgr.cloud - WEBHOOK_TUNNEL_URL=https://n8n.srv828430.hstgr.cloud - N8N_TUNNEL_URL=https://n8n.srv828430.hstgr.cloud labels: - "traefik.enable=true" - "traefik.http.routers.n8n.rule=Host(n8n.srv828430.hstgr.cloud)" - "traefik.http.routers.n8n.entrypoints=websecure" - "traefik.http.routers.n8n.tls.certresolver=letsencrypt" - "traefik.http.services.n8n.loadbalancer.server.port=5678" - "traefik.http.middlewares.n8n-strip-port.redirectregex.regex=^https://(.):5678/(.)" - "traefik.http.middlewares.n8n-strip-port.redirectregex.replacement=https://$1/$2" - "traefik.http.middlewares.n8n-strip-port.redirectregex.permanent=true" - "traefik.http.routers.n8n.middlewares=n8n-strip-port@docker" Expected behavior The generated callback URL should be:

bash

https://n8n.srv828430.hstgr.cloud/rest/oauth2-credential/callback and not with the internal :5678 port.

Temporary workaround I can bypass this by manually editing the callback URL in the browser, but that’s not viable for non-technical users or full automation.

Thank you for your help and feedback!