Docs / Servers
Cloud firewalls
6 minute read
A cloud firewall decides which traffic may reach your servers and leave them. You write the rules once and apply them to servers, or to every server with a tag. Firewalls are free.
1. How firewalls work
- A server with no firewall allows all traffic.
- Once any firewall applies to a server, every connection its rules don't allow is dropped, inbound and outbound. Replies to allowed traffic always pass.
- A server can have several firewalls. It gets every rule of all of them.
- Rules cover traffic from the internet and from your project's private network: a database server can accept PostgreSQL only from your web servers.
- The rules are enforced outside the server, on its network connection, so nothing inside the server can switch them off.
2. Create a firewall
Open Cloud firewalls → Create firewall. A new firewall starts with the usual defaults: SSH (port 22) in from all IPv4 addresses, and all TCP, UDP and ICMP out. Add the rules you need, pick servers or tags, and create it. The rules take effect within seconds.
simplicloud firewalls create web-fw --in ssh --in http --in https --tag web✓ Firewall web-fw created: 3 inbound, 3 outbound rules, 2 servers
3. Rules and sources
Each rule has a protocol, a port range and where the traffic may come from (inbound) or go to (outbound).
| Field | Values |
|---|---|
| Type | SSH, HTTP, HTTPS, MySQL, PostgreSQL, Redis, All TCP, All UDP, ICMP, or Custom |
| Protocol | TCP, UDP or ICMP |
| Port range | One port (8080), a range (8000-9000) or all. ICMP has no ports. |
| Sources / destinations | All IPv4 (0.0.0.0/0), IPv4 addresses and CIDR ranges, servers, tags, and load balancers once they are available |
Servers and tags stand for the servers' private addresses, kept up to date: tag a new server web and a rule with the source tag: web includes it straight away.
4. Apply it to servers and tags
On the firewall's Servers tab, add servers one by one or add a tag. Tag servers on their own page (the Firewall card), or from the CLI:
simplicloud servers tags web-3 web env:prodsimplicloud firewalls add-server db-fw orders-db-1simplicloud firewalls get web-fw
Each server's page shows which firewalls apply to it, whether they came from the server or one of its tags, and whether the rules are active.
5. Public SSH and source addresses
Servers don't have public addresses of their own yet: public SSH reaches them through the SimpliCloud SSH gateway (ssh -p 2xxxx). The gateway hides the client's address, so a firewall can't tell one SSH client on the internet from another.
- To allow public SSH, the SSH rule needs the source All IPv4.
- An SSH rule limited to specific addresses still works for traffic from your private network (other servers in the project), but public SSH through the gateway is then dropped.
- Every other port is only reachable from your private network, so address rules on those ports work exactly as written.
6. API
| Call | Does |
|---|---|
GET /v1/orgs/ORG/firewalls | Every firewall with its rules, servers, tags and status |
POST /v1/orgs/ORG/firewalls | Create: name, inboundRules, outboundRules, serverIds, tags |
PUT /v1/orgs/ORG/firewalls/ID | Replace the whole firewall |
POST|DELETE …/firewalls/ID/servers | Add or remove servers: {"serverIds": [...]} |
POST|DELETE …/firewalls/ID/tags | Add or remove tags: {"tags": [...]} |
DELETE /v1/orgs/ORG/firewalls/ID | Delete; its servers lose the rules |
GET /v1/orgs/ORG/servers/ID/firewalls | The firewalls on one server and whether they are active |
PUT /v1/orgs/ORG/servers/ID/tags | Set a server's tags: {"tags": [...]} |
DigitalOcean's field names (inbound_rules, droplet_ids, load_balancer_uids) are accepted too.