DEV Community

Philip Stayetski
Philip Stayetski

Posted on

Deploy an AI Agent to Production Behind a Firewall (Without Opening a Port)

Deploy an AI Agent to Production Behind a Firewall (Without Opening a Port)

The agent is built. It passes its tests. Locally, everything works. Then comes the part nobody puts in the demo: you need to deploy an AI agent to production behind a firewall, and something external has to reach it — a SaaS webhook that fires on customer events, a scheduler, another agent on a different cloud.

The agent is ready. The network is not. Every inbound path you'd normally use is blocked, and you're not allowed to open a port.

This is a deployment how-to for exactly that situation. Not a framework survey, not a mesh topology essay — the concrete problem of making a local agent reachable from the outside without exposing your network.

Deploy an AI Agent to Production Behind a Firewall: The Real Problem

Strip away the agent-specific language and the problem is ordinary: you have a process that must receive requests, but it sits on a network that permits no inbound connections.

For a web service you'd solve this with a public IP and a load balancer. Agents make that harder in two ways:

  • They're often deployed where the data lives — on-prem, in a VPC with strict egress-only rules, on a laptop that roams between networks. There is no static public IP to point a webhook at.
  • They're long-running and stateful. A tunnel that dies with the developer's session isn't production. The address has to be stable even when the machine behind it isn't.

So the requirements are: stable addressing, no inbound ports, and something that survives restarts, IP changes, and cloud moves.

Why the Usual Answers Don't Fit

Let's be fair to the standard toolbox, because each option is right in some context.

Port forwarding. The classic. You open a port on the router or the security group and map it to the agent. It works until the agent moves hosts, the office IP changes, or security reviews the rule. Also, exposing an agent's endpoint directly to the internet is a real attack surface — an agent is a process that acts, and acting surfaces are what prompt-injection researchers poke at.

A reverse proxy with a static IP. Solid, boring, correct — if you control infrastructure. You need a box with a public address, TLS termination, and a secure channel back to the agent. That's a real deployment. If you're shipping one agent to a customer's network, you don't want to ship a proxy with it.

ngrok-style tunnels. Excellent for demos and staging. The tunnel endpoint is a third party, and the address is tied to a session that can churn. For a webhook target that must be stable for years, it's a fragile foundation — though a genuinely useful one for the "prove it works" step.

A VPN. Joins networks, which solves reachability — but it also joins trust. In a VPN, if a node is on the network, it's treated as trusted. For agent-to-agent traffic you often want the opposite: reachability and explicit per-peer trust, decided independently. (This is the classic "joined ≠ trusted" distinction that overlay networks were built to address.)

None of these are wrong. They're just shaped for a different deployment than "one agent, behind an unknown firewall, reachable from the outside."

The Outbound-Only Option: An Overlay Network

There's a fourth shape worth taking seriously: run the agent as a node on an overlay network, where connectivity is built from outbound-only tunnels.

The idea: the agent's daemon dials out to a rendezvous registry once, establishes encrypted UDP tunnels, and gets a permanent virtual address that survives restarts, IP changes, and moves between clouds. Once it has that address, other agents — and the services that need to reach it — can send to it directly, no inbound ports on your side. NAT traversal (STUN + hole-punching, with relay fallback) handles the "we're both behind NAT" cases.

This is exactly what Pilot Protocol implements. It's an open-source overlay network for AI agents: Go, zero external dependencies, AGPL-3.0. Every agent gets a stable address, and communication is encrypted end-to-end (X25519 key exchange, AES-GCM).

The part that matters for production deployment is the trust model. Before two agents talk, they do an explicit handshake — mutual approval. Reachability and trust are decoupled. You can be reachable by the network without being trusted by any given peer, which is a much better default for an agent that acts on messages.

What Deployment Looks Like in Practice

Here's the whole flow, from a clean machine behind a firewall:

curl -fsSL https://pilotprotocol.network/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

The daemon starts and registers the node:

pilotctl daemon start
Enter fullscreen mode Exit fullscreen mode

That's the "opening a port" step — except there isn't one. The daemon dials out; nothing inbound is opened. Your agent gets its virtual address and is now reachable by name.

Another agent (or a service you control) reaches it the same way it reaches any peer:

pilotctl send-message <agent-address> --data 'task: summarize the new support tickets'
Enter fullscreen mode Exit fullscreen mode

Trust is explicit, per peer:

pilotctl handshake <agent-address> "production webhook consumer"
Enter fullscreen mode Exit fullscreen mode

The consumer side approves; after that, messages flow. If the agent's machine is restarted, moved to another cloud, or given a new IP, the address stays the same — the peers don't care where the agent physically lives.

Webhooks, Other Agents, and the App Store

For the "SaaS webhook needs to reach my agent" case specifically, two docs pages matter:

  • Webhooks — the daemon can receive real-time HTTP notifications for daemon events, which is how an agent stays reactive without polling.
  • Gateway — an optional separate binary that bridges IP traffic onto the overlay, so plain TCP tools (curl, browsers, anything) can reach overlay peers. Useful when the thing calling your agent isn't itself an agent.

And since the agent is now a node on a network with a directory, it doesn't just receive — it can discover. The same deployment that makes the agent reachable also makes it able to find service agents and install capability apps from the app store (pilotctl appstore catalogue, pilotctl appstore install <id>, pilotctl appstore call <id> <method> '{}'). One install, and the agent has access to the network's tooling — no API keys to provision.

The Checklist

If you're deploying an agent behind a firewall today, run through this:

  1. No inbound ports. Prefer outbound-only connectivity. If someone asks for a firewall rule, ask why.
  2. Stable address. The webhook target must not change when the machine moves. A permanent virtual address beats a rotating tunnel URL.
  3. Trust, separate from reachability. Being on the network should not mean being trusted. Explicit per-peer approval for anything that can trigger agent actions.
  4. Encryption by default. Agent traffic is worth protecting like any other production traffic.
  5. Reachability is a feature, not an endpoint. Once the agent is reachable, it can discover peers, query service agents, and install apps — the deployment pays for itself.

The agent was the hard part. The last mile — making it reachable — doesn't have to be.

If you want to see the mechanics before committing, the Pilot Protocol docs walk through addressing, transport, and the trust model in enough detail to evaluate it against your own deployment constraints. And if you want to skip the reading and see it run:

curl -fsSL https://pilotprotocol.network/install.sh | sh
Enter fullscreen mode Exit fullscreen mode

Top comments (0)