Webhook Deploys Worked Until the Network Said No
Updated November 26, 2026

The webhook (a URL GitHub calls when something happens) worked perfectly, as long as the request came from inside my own network.
Over a weekend in June I set out to automate deployments for my documentation site. Every update meant the same routine: change the content, rebuild the Docker image by hand, restart the container through Portainer, and check the site. Five minutes or more each time, and every manual step was a chance to skip one. The goal was simple. Push to a deploy branch on GitHub, and the site rebuilds itself.
By Sunday the automation was done and tested. It just couldn't be reached by the one service that needed to call it.
What I Built
The pieces were small:
- A deploy branch. Day-to-day work happened on the main branch; merging into deploy and pushing meant "publish this".
- A small Node.js service with one endpoint. When called, it pulled the repository, rebuilt the site image with
--no-cacheso no stale content survived, and restarted the site container. - A dedicated SSH (secure shell) key pair for this one job, registered with GitHub as a read-only deploy key on that one repository. The key was mounted read-only into the container, and the service ran as a non-root user.
- Both containers defined in a single stack file, on the same Docker network as the reverse proxy, reaching each other by DNS name instead of IP address.
I tested it from inside the network by calling the endpoint directly with curl. Git pull over SSH: worked. Fresh image build: worked. Container restart with the new content: worked. The whole cycle finished in under a minute.
Then I pointed GitHub's webhook at it.
The Request That Never Arrived
GitHub's delivery log showed a 308 Permanent Redirect for every attempt. I tried the obvious things. I switched the public DNS record between proxied and DNS-only at Cloudflare. I adjusted the nginx configuration for the webhook path. The result never changed.
I was debugging the wrong layer. A redirect means something on the way answered, and it wasn't my webhook service. The 308 had to be coming from Cloudflare, where I run a proxy in front of all of my public-facing services. The docs site was one of them at the time.
When I stepped back and traced the path from the outside in, the bigger answer was plain: even without the redirect, there was no path. The server lived on an internal network. The firewall had no port forward to it, by design. A request from GitHub's servers had nowhere to go except whatever sat at the edge, and nothing at the edge knew how to hand it to an internal container.
One detail worth knowing: GitHub doesn't follow redirects on webhook deliveries. A 3xx response counts as a failed delivery. So even a well-meaning HTTP-to-HTTPS redirect at the edge is enough to break a webhook.
Three Ways Forward
At that point the problem was no longer code. It was a decision about my network, and I wrote the options down before touching anything.
Forward a port to the internal server. The fastest fix. It also means a service with Docker access, running on the same host as everything else, answering requests from the whole internet. The webhook container needed the Docker socket to rebuild and restart containers, and access to the Docker socket is effectively root on the host. An internet-facing endpoint in front of that's a bad trade for saving five minutes per deploy.
Put the webhook receiver in a DMZ (a separate network segment for anything the internet may reach). A separate network segment for anything the internet is allowed to reach, with strict rules about what it may talk to on the inside. This is the right shape for public services, but it was more network work than the documentation site justified that weekend.
Bring the trigger inside. Run a Git server on the internal network, or poll GitHub for changes on a schedule. Either way, the connection goes outbound from my network, and nothing on the internet has to reach in.
The Decision
I deferred the webhook and kept the work. The site went back to a Portainer stack deployment, and updates became: change the content, build a new image, deploy it through the stack. Manual, but predictable, and it opened nothing to the internet.
Nothing was thrown away. The webhook service, the deploy key and the stack definition stayed in the repository, and I wrote a decision log with the three options and their costs. The automation itself was finished and proven. What was missing was a safe network path, and that deserved its own decision.
What I'd Tell Someone Doing This Tomorrow
Before you build anything triggered by an outside service, draw the path the request will take from the internet to your code: DNS, the edge, the firewall, the proxy, the container. If any hop on that drawing doesn't exist yet, that's the first problem to solve. It's a network and security decision, so make it with whoever owns the firewall before you write code.
When you debug a webhook, read the delivery log's status code literally. A 308 or 301 means something answered with a redirect, and a timeout means nothing answered at all. Both tell you how far the request got.
And when the safe answer is "not yet", ship the manual version, keep the automation in the repository, and write a short decision log: the options, what each one costs, and which one you picked.
Update: the decision log turned out to be a plan. Later I built a DMZ segment for the services the internet is allowed to reach, with its own reverse proxy, and moved my repositories to a self-hosted GitLab inside my network. Its CI (continuous integration) pipelines run where the servers are, so a push starts a deploy without any inbound connection from outside.
Enjoyed this article?
Subscribe to get notified about new posts on software engineering, AI development, and infrastructure.
No spam, unsubscribe anytime.