Firewall
Every server has its own firewall: everything closed from outside until you open a port, everything open going out.
How it works
- The firewall belongs to the server: the rules are on its page, under Firewall. There is no separate object to create and then attach.
- Nothing gets in from outside unless it matches a rule (Nothing gets in unless a port is open here). The exception is ping, which always gets through.
- Everything going out is allowed (Everything gets out).
- Everything from the project's private network is let in: you do not need rules between your servers (see Networking).
- A rule states protocol, port (or port range) and from where (From): a single address or a network, IPv4 or IPv6.
- It applies to the server's public IPv4 and IPv6 addresses, depending on the source:
0.0.0.0/0is the whole internet over IPv4,::/0the whole internet over IPv6; a rule with no source (only possible for 80 and 443) applies to everyone, over IPv4 and IPv6.
The rules for ports other than 80 and 443
To protect you from a common mistake (the database or SSH port open to the world), ports other than 80 and 443 have two extra rules:
- they can only be opened by saying from where: the source is required;
- opening them to the whole internet (
0.0.0.0/0or::/0) can only be done by someone with Can manage or by the project owner. People with Can edit open them to specific addresses and networks.
Ports 80 and 443 can be opened to everyone by anyone with Can edit.
Opening a port
On the server page, under Firewall:
- Port: the number, from 1 to 65535;
- Protocol:
tcporudp; - From: the source. The Me button fills in the address you are connected from right now (handy for SSH from your office). For 80 and 443 you can leave it empty: that means anywhere;
- Open.
When creating a server you can already open 80, 443 and 22 (see Virtual machines).
Changing a rule
Click the pencil (Change rule) next to the rule. You can change:
- Protocol:
tcp,udporicmp; - Ports: one port (
22) or a range (1000-2000); foricmpports do not matter; - From: the source, with the same Me button.
Then Save. The rule is replaced and gets a new id. The same rules as for opening apply.
Port ranges and the icmp protocol are set from here (and from the API with Cloud/updatePort), not from the field used to open a port.
Closing a port
The bin (Close port) next to the rule. Whatever the rule let in stops getting in immediately.
Examples
| What you want | Rule |
|---|---|
| A website open to everyone | tcp 80 and tcp 443, From empty |
| SSH only from your office | tcp 22 from 203.0.113.7 (or the office network, for example 203.0.113.0/24) |
| SSH from your current address | tcp 22, Me button |
| A database reachable only from another of your servers | No rules: use the project's private network |
| WireGuard open to everyone (needs Can manage) | udp 51820 from 0.0.0.0/0, and another from ::/0 for IPv6 |
For developers
| What | Method | MCP tool | Role |
|---|---|---|---|
| A server's rules | Cloud/getFirewall (server_id) |
cloud_get_firewall |
viewer |
| Open | Cloud/openPort (server_id, port, protocol: tcp/udp, source?) |
cloud_open_port |
operator (admin for non-web ports to the whole internet) |
| Change | Cloud/updatePort (server_id, rule_id, protocol: tcp/udp/icmp, port, port_max?, source?) |
cloud_update_port |
as above |
| Close | Cloud/closePort (server_id, rule_id) |
cloud_close_port |
operator |
| The address you are calling from | Customer/getMyAddress |
— | panel only |
Each rule has id, protocol, port, port_max, source (null = everyone). All writes accept dry_run.
Example, SSH from one address:
curl -s https://gigakube.ch/api/rpc \
-H "Authorization: Bearer $GIGAKUBE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"Cloud/openPort","params":{"call_data":{"server_id":"<id>","port":22,"protocol":"tcp","source":"203.0.113.7/32"}}}'
Without source for a port other than 80 and 443 the response is a CLOUD_INVALID_REQUEST error (Ports [22] need an explicit source); to the whole internet without the role, CLOUD_FORBIDDEN.