Hetzner Cloud icon

Hetzner Cloud

Manage servers, volumes, networks and more in Hetzner Cloud

Firewall → Set Rules

AI-generated

Summary

Replaces all rules of a Hetzner Cloud firewall with the rules array you supply, via POST /v1/firewalls/{id}/actions/set_rules.

Inputs

  • Firewall (required) — The firewall to modify, chosen from a searchable list of the project's firewalls or entered by numeric ID. The ID goes into the request URL.
  • Rules (JSON) — JSON array of firewall rule objects, for example [{"direction":"in","protocol":"tcp","port":"443","source_ips":["0.0.0.0/0","::/0"]}]. The default is []. It is sent as the body's rules property and replaces every existing rule. If the value is empty or '{}', no rules are sent. Invalid JSON raises a node error.
  • Request Options — Node-level settings: batching (items per batch and interval in ms), ignore SSL issues, an HTTP proxy, and a timeout (default 10000 ms).

Output shape

The actions array from the Hetzner API response. Each entry is an action object describing the asynchronous set_rules operation, with fields such as id, command, status and progress.

The call is asynchronous, so the returned status may still be 'running'. To confirm completion, use the Action resource's Get operation. The node does not poll. The default [] sends an empty rules array, which removes all rules from the firewall.

Examples

Example 1: Open HTTPS and SSH to the world on a web firewall

Firewall: pick 'web-firewall' from the list. Rules (JSON): an array with two inbound tcp rules, ports 443 and 22, and source_ips ["0.0.0.0/0","::/0"].

Example 2: Remove all rules from a firewall by ID

Firewall: By ID '42'. Rules (JSON): [].

Links

Discussion