Firewalls
A Cloud Firewall decides what traffic reaches the Droplets it’s applied to, before it reaches them. It drops everything inbound that no rule allows. Apply it to Droplets by id, or by tag so that every Droplet with the tag, now or later, is covered.
Create a firewall
Section titled “Create a firewall”yield* DigitalOcean.Firewall("Web", { tags: ["web"], inboundRules: [ { protocol: "tcp", ports: "443", addresses: ["0.0.0.0/0", "::/0"] }, { protocol: "tcp", ports: "22", addresses: ["203.0.113.4/32"] }, ], outboundRules: [{ protocol: "tcp", ports: "1-65535", addresses: ["0.0.0.0/0", "::/0"] }],});ports is one port or a range like "8000-8100". A rule’s sources can also be Droplet ids, load balancer ids, Kubernetes cluster ids or tags.
Apply it to Droplets
Section titled “Apply it to Droplets”tags covers every Droplet with the tag, including ones created later; dropletIds: [host.dropletId] names specific ones. Give a Droplet the tag with its own tags prop.
Limits
Section titled “Limits”- A firewall with no outbound rules blocks all outbound traffic, including package installs.
- Cloud Firewalls apply to Droplets and Kubernetes nodes; managed databases have their own trusted sources.