Strict Network Egress Policy Control
Allow and deny outbound connections per Sprite, enforced on the host, up to blocking all outbound access.
On this page
What it is
A network policy controls where a Sprite can connect to on the internet. You write a list of allow and deny rules, and the host enforces them outside the Sprite, so nothing running inside can bypass them.
- With no rules (the default), a Sprite can reach the whole public internet.
- With rules, only the domains you allow will resolve and connect. Everything else is denied.
You can block outbound access entirely, or restrict a Sprite to specific services and public internet destinations.
Why it matters: lock each workload down to only the connections it needs. Enforcement happens outside the guest, so the policy doesn’t depend on any software running inside the Sprite. This is especially useful for AI agents and untrusted code.
Step by step: lock a Sprite down
1. Look at the current policy
ssh my-org@sprites.dev sprite network-policy get dev
# HTTP API
curl -sS "https://api.sprites.dev/v1/sprites/dev/policy/network" \
-H "Authorization: Bearer $SPRITES_TOKEN"
2. Write your rules
Start from the curated defaults and add the APIs your workload uses:
{"rules": [
{"include": "defaults"},
{"domain": "api.example.com", "action": "allow"},
{"domain": "*.internal.example.com", "action": "allow"}
]}
3. Apply the policy
policy='{"rules":[{"include":"defaults"},{"domain":"api.example.com","action":"allow"},{"domain":"*.internal.example.com","action":"allow"}]}'
ssh my-org@sprites.dev "sprite network-policy set dev --input-json '$policy'"
# HTTP API
curl -sS -X POST "https://api.sprites.dev/v1/sprites/dev/policy/network" \
-H "Authorization: Bearer $SPRITES_TOKEN" \
-H "Content-Type: application/json" \
-d '{"rules":[{"include":"defaults"},
{"domain":"api.example.com","action":"allow"},
{"domain":"*.internal.example.com","action":"allow"}]}'
Adding the first rules to a Sprite (or removing all of them) cold-restarts it. Replacing one set of rules with another applies in place, but it closes every proxied connection, including WebSockets and gRPC streams the new rules still allow.
4. Test it
Check that an allowed domain works (pypi.org is in the defaults preset) and that anything else is refused:
ssh my-org@sprites.dev "sprite exec dev 'curl -sS -o /dev/null -w \"%{http_code}\\n\" https://pypi.org/'"
ssh my-org@sprites.dev "sprite exec dev 'curl -sS https://example.org/ || echo blocked'"
A denied HTTP(S) request gets 403 with an x-sprite-egress-error: policy_denied header.
5. Remove the policy
Go back to unrestricted access:
ssh my-org@sprites.dev sprite network-policy delete dev
# HTTP API
curl -sS -X DELETE "https://api.sprites.dev/v1/sprites/dev/policy/network" \
-H "Authorization: Bearer $SPRITES_TOKEN"
Writing rules
Domain rules
{"domain": "api.example.com", "action": "allow"}
{"domain": "*.example.com", "action": "allow"}
{"domain": "*", "action": "deny"}
*.example.commatchesexample.comand all its subdomains.*matches everything.- Exact names beat wildcards, and longer suffixes beat shorter ones. So you can deny
*.example.comand still allowapi.example.com.
Blocking all outbound access
Because any policy with rules denies whatever it doesn’t allow, a single deny-everything rule cuts the Sprite off from the internet:
policy='{"rules":[{"domain":"*","action":"deny"}]}'
ssh my-org@sprites.dev "sprite network-policy set dev --input-json '$policy'"
Curated presets
include pulls in a maintained list of domains:
| Preset | Covers |
|---|---|
ai-apis | AI model APIs |
package-registries | Language package registries |
os-packages | OS package mirrors |
source-hosting | Source code hosting |
container-registries | Container registries |
cloud-apis | Cloud provider APIs |
fly | Fly.io |
telemetry | Telemetry endpoints |
schemas | Schema hosts |
defaults | All of the above |
For a tight policy, include only the presets you need rather than defaults:
{"rules": [
{"include": "package-registries"},
{"include": "ai-apis"}
]}
Method and path rules
Limit a domain rule to certain HTTP methods or paths. /a/b matches exactly; /a/* matches /a and everything under it. This example allows Google APIs except PageSpeed Insights:
{"rules": [
{"domain": "www.googleapis.com", "action": "allow"},
{"domain": "www.googleapis.com", "action": "deny", "paths": ["/pagespeedonline/*"]}
]}
Path rules never see the query string, and in testing, deny rules matched paths regardless of case (/PageSpeedOnline/... was blocked too). On a host covered by a path rule, ambiguous paths (with . or .. segments, //, ;, \, or an encoded / or \) are always refused.
Address rules (non-HTTP traffic)
Only DNS (53), HTTP (80) and HTTPS (443) go through the policy proxy. Everything else, including QUIC, is blocked unless an address rule allows it. For example, to reach an external Postgres database:
{"address": "db.example.com", "protocol": "tcp", "port": 5432}
address takes a public IPv4 address, a CIDR, or a DNS name. protocol is tcp or udp with a port (not 53), or icmp without one.
Address-rule traffic goes out uninspected, bypassing domain and path rules, even on ports 80 and 443. A name on a shared CDN or cloud load balancer opens that address, and every service behind it, on that protocol and port.
HTTPS inspection and certificates
When a Sprite has rules, its HTTPS traffic is decrypted and re-signed with a certificate authority unique to that Sprite. This is how domain and path rules work for HTTPS. Sprites sets these environment variables for commands, services and shells:
SSL_CERT_FILE,REQUESTS_CA_BUNDLE,CURL_CA_BUNDLE,GIT_SSL_CAINFO,PIP_CERT,AWS_CA_BUNDLE,CARGO_HTTP_CAINFO→/.fly/run/egress/ca-bundle.pem(system CAs plus the Sprite’s)NODE_EXTRA_CA_CERTS→/.fly/run/egress/egress-ca.pem(the Sprite’s CA only)
Most tools just work. Clients with their own trust store, such as a Java keystore or NSS, need egress-ca.pem imported. A cold start or host move brings a new CA; the files and variables follow automatically, but anything you imported by hand must be imported again.
Know the limits
- A policy limits where a Sprite connects, not what data leaves. Any allowed service that accepts uploads can carry data out. Some presets include such services:
source-hostingaccepts pushes and gists, andcloud-apisreaches every Cloud Storage bucket. - Services that fetch URLs for you effectively allow the whole internet. Presets leave out the ones known (like PageSpeed Insights), but check any domain you allow.
- Certificate pinning and end-to-end mTLS don’t work through the proxy. Use an address rule for that traffic.
- IPv6 isn’t supported, and DNS answers only A records.
- VPN clients such as Tailscale won’t connect on domain rules.
- Over the HTTP API, policy endpoints currently work only for Sprites in the default cluster; for other clusters they return
502. The SSH commands (sprite network-policy get|set|delete CLUSTER/NAME) work in any cluster. - A Sprite can’t change its own policy:
sprite-envinside it gets403 network_policy_read_only.