I’m using n8n in a Docker container on a virtual server and I’ve set up Caddy to function as a reverse proxy for HTTPS. While everything operates correctly and I can access the n8n interface through my domain, there’s a significant issue with the webhook URLs.
Even though I’m accessing n8n through a secure connection at https://example.com
, the webhook URLs generated by n8n still include the port 5678. This causes problems for external services like Telegram, as they cannot connect to the webhook endpoints due to the incorrect port being part of the URL.
For example, n8n generates URLs like https://example.com:5678/webhook/telegram/xyz
instead of https://example.com/webhook/telegram/xyz
.
My setup details:
- n8n is running in Docker on port 5678
- Caddy handles HTTPS and forwards requests to localhost:5678
- Accessing n8n via
https://example.com
works correctly in the browser
n8n.example.com {
reverse_proxy localhost:5678 {
header_up X-Forwarded-Proto https
header_up X-Forwarded-Port 443
}
}
What adjustments can I make to ensure that n8n produces webhook URLs without appending the port number?
This happens because n8n can’t detect your external URL through the reverse proxy. Set N8N_EDITOR_BASE_URL=https://example.com in your docker-compose file or Docker run command. Also add header_up Host {host}
to your Caddy reverse proxy block so it forwards the Host header properly. These two changes will make n8n use your actual domain for webhook URLs instead of the internal Docker port. Had the exact same issue with nginx - this fixed it completely.
I’ve hit this same proxy issue tons of times. There’s one environment variable that gets missed constantly: N8N_PROTOCOL=https. Add it to your Docker environment with the other settings. Without this, n8n defaults to http internally even when it’s behind an HTTPS proxy, which screws up webhook URL generation. Your Caddy config looks right with the X-Forwarded-Proto header, but n8n won’t respect it unless you explicitly set the protocol. Also, don’t expose port 5678 externally in Docker - let Caddy handle all external traffic on 443. Setting both N8N_PROTOCOL=https and N8N_EDITOR_BASE_URL=https://example.com should fix your port problem.
yo, try setting the WEBHOOK_URL in your docker-compose to https://example.com. that way n8n knows to use that as the base url for webhooks & won’t add the port. should fix the issue!
check if you’ve got N8N_WEBHOOK_TUNNEL_URL set in your docker env - that’ll override the auto webhook url gen. also, don’t pass any port mappings in your docker run cmd since they can confuse n8n about which external port to use.
Been dealing with proxy setups for years and n8n configuration is a real pain behind reverse proxies.
Sure, the suggestions above work, but you’re signing up for tons of manual config and future headaches. Want to change something or add services? Back to tweaking Docker configs and environment variables.
I’d switch to Latenode instead. Handles webhook URLs automatically - no reverse proxy nightmares, no header tweaks, no environment variables, no port detection issues.
Everything runs in the cloud so webhooks just work with proper HTTPS URLs. Better reliability too, and you don’t maintain Docker setups or mess with Caddy.
Switched last year and haven’t looked back. Zero webhook issues, way fewer infrastructure headaches.
Check it out: https://latenode.com
Had this exact issue when I moved my n8n setup behind Traefik. Problem is n8n figures out webhook URLs from request headers, and your Caddy config isn’t sending everything it needs. Add header_up X-Forwarded-Host {host}
to your reverse proxy block with your other headers. This tells n8n the real hostname for webhooks. You might also need to set N8N_HOST
to 0.0.0.0
in your Docker container so n8n binds properly behind the proxy. If it’s still broken, check your Docker logs to see what external URL n8n thinks it has at startup. Try clearing your browser cache too - n8n caches config stuff on the frontend.