OAUTH issue while running n8n docker behind cloudflared CDN

Describe the problem/error/question

When running n8n in docker and exposing it via CDN (Cloudflared) one cannot configure correct oauth callback URL

Setup
Internet → https://public-url:443 → Cloudflared tunnel forward to http://localhost:5678 → docker foward port :5678:5678 into n8n docker.

URL callback generated by N8N for OAUTH is "https://public-url:5678/rest/oauth2-credential/callback

which is not handled by Cloudflare.
In docker settings one might change the environments to
-e N8N_HOST=“public-rurl”
-e N8N_PROTOCOL=“https”
-e N8N_PORT=“443”
-e WEBHOOK_TUNNEL_URL=“public-url”
-e VUE_APP_URL_BASE_API=“public-url” \

which causes whole n8n in docker to run on port 443.

Expected behaviour is to have environment variable just changes URL:port for OAUTH URL callback.

The only solution to make OAUTH working behind CDN is to switch N8N to port 443 or to have Cloudflare CDN forwarding port 5678 from public access (not recommended by security).

What is the error message (if any)?

OAuth 501 time out

Information on your n8n setup

sudo docker exec -it n8n env | grep -E “N8N|VUE_APP”
N8N_HOST=n8n.maziak.eu
N8N_PROTOCOL=https
N8N_PORT=5678
VUE_APP_URL_BASE_API=https://n8n.maziak.eu
N8N_VERSION=1.74.3
N8N_RELEASE_TYPE=stable

Runnint in Docker
Debian Linux

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Any news on the case? Same problem happening here…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.