Hosted in Lagos: servers from ₦10 an hour, Spaces from ₦6,750 a month →
Docs menu

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).

FieldValues
TypeSSH, HTTP, HTTPS, MySQL, PostgreSQL, Redis, All TCP, All UDP, ICMP, or Custom
ProtocolTCP, UDP or ICMP
Port rangeOne port (8080), a range (8000-9000) or all. ICMP has no ports.
Sources / destinationsAll 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.

With no outbound rules, a server can't send anything out, so updates and downloads stop working. Keep the default outbound rules unless you mean to lock that down.

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:

Terminal
simplicloud servers tags web-3 web env:prod
simplicloud firewalls add-server db-fw orders-db-1
simplicloud 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.
Removing SSH from all IPv4 locks you out of public SSH. The browser console on the server's page still works, whatever the firewall says.

6. API

CallDoes
GET /v1/orgs/ORG/firewallsEvery firewall with its rules, servers, tags and status
POST /v1/orgs/ORG/firewallsCreate: name, inboundRules, outboundRules, serverIds, tags
PUT /v1/orgs/ORG/firewalls/IDReplace the whole firewall
POST|DELETE …/firewalls/ID/serversAdd or remove servers: {"serverIds": [...]}
POST|DELETE …/firewalls/ID/tagsAdd or remove tags: {"tags": [...]}
DELETE /v1/orgs/ORG/firewalls/IDDelete; its servers lose the rules
GET /v1/orgs/ORG/servers/ID/firewallsThe firewalls on one server and whether they are active
PUT /v1/orgs/ORG/servers/ID/tagsSet a server's tags: {"tags": [...]}

DigitalOcean's field names (inbound_rules, droplet_ids, load_balancer_uids) are accepted too.

Was this page helpful?

Related guides