How do I expose an n8n webhook over HTTPS?
Configure DNS, the reverse proxy and WEBHOOK_URL, then test the production URL. External integrations typically require HTTPS.
External integrations typically require HTTPS. Port 5678 should remain listening locally behind Caddy or Nginx.
Step-by-step procedure
-
Create the DNS record
Add an A record for n8n.example.com pointing to the VPS IPv4 address.
-
Configure n8n
Set N8N_HOST, N8N_PROTOCOL=https and WEBHOOK_URL in Compose, then recreate the container.
-
Install Caddy
Make Caddy listen on ports 80 and 443 and reverse-proxy to 127.0.0.1:5678.
-
Open the firewall ports
Allow HTTP and HTTPS. Keep 5678 closed to the public network.
-
Test the production URL
Activate a Webhook node, copy the production URL, then call it with curl or the source application.
Caddyfile
n8n.example.com {
reverse_proxy 127.0.0.1:5678
}
Test
curl -X POST https://n8n.example.com/webhook/YOUR_PATH \
-H "Content-Type: application/json" \
-d '{"source":"aclclouds"}'
Check DNS, ports and Caddy
dig +short n8n.example.com
ss -lntp | grep -E ':(80|443) '
ufw allow 80/tcp
ufw allow 443/tcp
journalctl -u caddy -n 50 --no-pager
Before you start
Let’s Encrypt only issues the certificate if the domain already points to the VPS and port 80 is reachable from the Internet. Create the DNS record first, wait until it resolves, then start Caddy.
- dig +short n8n.example.com returns the VPS IPv4.
- No other service, such as Nginx or Apache, is already listening on ports 80 and 443.
- If you enabled the panel firewall (“Additional tools” > “Firewall”), add one TCP rule for 80 and one for 443.
- If the domain goes through Cloudflare, leave it in “DNS only” mode (grey cloud) during setup.
Understanding webhook URLs
A Webhook node has two addresses. The test URL, under /webhook-test/, only answers while the editor is waiting for a call, after a click on “Listen for test event”. The production URL, under /webhook/, only answers once the workflow is published.
n8n builds these addresses from WEBHOOK_URL. If the variable is missing, it shows an address with localhost:5678 that the external application can never reach.
Check that everything works
curl -I https://n8n.example.com must answer with no certificate error. The guide’s curl -X POST test returns {"message":"Workflow was started"} and a new line appears in the workflow’s “Executions” tab.
Frequently asked questions
Why does the call return 404 with is not registered?
n8n knows no active webhook for this path and method. Publish the workflow for the /webhook/ URL, or click “Listen for test event” before calling /webhook-test/. Also check that the node’s HTTP method, POST or GET, matches the one used in the call.
Caddy cannot get the certificate, what should I do?
Read journalctl -u caddy -n 50. NXDOMAIN means the domain does not resolve yet; Timeout during connect means port 80 is blocked. Fix the cause, then run systemctl restart caddy. After several failures, Let’s Encrypt temporarily refuses new attempts for that name.
Why does the Webhook node URL still contain localhost:5678?
WEBHOOK_URL is missing or the container was not recreated. Add WEBHOOK_URL=https://n8n.example.com/ in compose.yaml, then run docker compose up -d. docker compose restart does not reload changed variables.
What does 502 Bad Gateway mean?
Caddy is running but cannot reach n8n. Check that the container is running with docker compose ps and that curl -s http://127.0.0.1:5678/healthz answers. The port in the Caddyfile must be the one published by Compose.