Network policies only apply to traffic directly to and from Machines. They do not affect traffic routed through the Fly Proxy.
How it works
A network policy contains:- A
selectorto match which Machines the policy applies to. - A list of
rulesfor ingress or egress, specifying allowed ports and protocols.
Restricting egress traffic to HTTP/HTTPS
For example, if you’re running an app that should only make outbound HTTP and HTTPS requests, you can create a policy like this:<FLY_API_TOKEN> and my-app-name with your actual values.
Selectors
Selectors determine which Machines your network policy applies to. You can target Machines using one or more of the following methods:All Machines in an app
To apply a policy to every Machine in your app:Specific Machine IDs
To target individual Machines by their unique identifiers:Metadata matching
To select Machines based on their metadata attributes:Rules
Each rule has:action: Onlyallowis supported.direction: Eitheringressoregress.ports: A list of port and protocol objects.
API summary
Create or update a policy
id field to update an existing policy.
List policies
Delete a policy
Troubleshooting
- After creating or updating a policy, restart or redeploy the Machines for changes to take effect.
- Use direct IP addresses (not hostnames) to test blocked traffic to avoid DNS masking.
- Make sure your
selectoris correct and matches the Machines you expect. - If traffic is still allowed unexpectedly, check if it’s going through the Fly Proxy.