# Configuring Web Application Firewall | Cycle.io

Canonical URL: https://cycle.io/docs/portal/configuring-web-application-firewall

## Configuring Web Application Firewall.

In the portal, environments using the [v1 load balancer](https://cycle.io/docs/platform/load-balancer-service#native-load-balancer-v1-vs-haproxy) can also configure a web application firewall. This is done on the firewall page in the load balancer modal.

To get there:

1.  Environments from the main, left-hand navigation.
2.  Select the environment from the first column.
3.  Scroll down to the services tile, and click on the manage tab of the load balancer.
4.  Select the Firewall page.
    
    ![services section](https://cycle.io/_cdn/docs-c80c4045-services-summary-1334x766-webp.webp)
    

The controller must be set to `Enable Custom Config` for the firewall config to be applied.

After enabling the `Firewall Configuration`, the user sees an example `Rule` entry.

### Firewall Rule Fields

Each `Rule` is comprised of the following fields:

<div class="joplin-table-wrapper"><table class="lexical-table" style="border-collapse:collapse"><tbody><tr class="lexical-table-row"><th class="lexical-table-cell lexical-table-cell-header-1" style="border:1px solid #ccc;padding:8px"><p>Field</p></th><th class="lexical-table-cell lexical-table-cell-header-1" style="border:1px solid #ccc;padding:8px"><p>Description</p></th></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>description</p></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>A text description of the rule, providing context or notes about what the rule is intended to do.</p></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>skip</p></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>A boolean value indicating whether the rule should be skipped (<code>true</code>) or processed (<code>false</code>).</p></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>type</p></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>Specifies the action of the rule: <code>"allow"</code>, <code>"deny"</code> (connection disconnect), or <code>"block"</code> (HTTP 403).</p></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>expires</p></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>Optional expiration date for the rule. If set, the rule is automatically disabled after this date.</p></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>match</p></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>Determines how conditions are evaluated: <code>"any"</code> (at least one must match), <code>"all"</code> (every condition must match), or <code>""</code>.</p></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>sample</p></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>Optional percentage (0–100) controlling what portion of requests the rule applies to. <code>100</code> = all requests, <code>0</code> = none.</p></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>conditions</p></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><p>An array of conditions that must be met for the rule to apply. Each condition contains:</p></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><ul class="list-bullet"><li data-index="01" value="1"><strong>type</strong>: The type of match to perform (e.g., <code>"ip-match"</code>).</li></ul></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><ul class="list-bullet"><li data-index="01" value="1"><strong>operator</strong>: The comparison operator to use (e.g., <code>"=="</code>).</li></ul></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><ul class="list-bullet"><li data-index="01" value="1"><strong>key</strong>: Optional. A specific attribute to target within the condition type (e.g., a header name for <code>http-header-match</code>).</li></ul></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><ul class="list-bullet"><li data-index="01" value="1"><strong>value</strong>: The value to compare against (e.g., an IP address). For IP addresses, both addresses and CIDRs are supported.</li></ul></td></tr><tr class="lexical-table-row"><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"></td><td class="lexical-table-cell lexical-table-cell-header-0" style="border:1px solid #ccc;padding:8px"><ul class="list-bullet"><li data-index="01" value="1"><strong>regex</strong>: When <code>true</code>, the <code>value</code> is treated as a regular expression pattern instead of a literal string. Default <code>false</code>. Regex can only be used with the <code>==</code> and <code>!=</code> operators. Use the pattern itself for other comparisons. For example, <code>(.*)my-string(.*)</code> matches any value that contains <code>my-string</code>.</li></ul></td></tr></tbody></table></div>

#### Supported Types

The currently supported condition types are listed below. Note that the HTTP-aware types (\`http-url-match\`, \`http-method-match\`, \`http-header-match\`, \`http-body-match\`) require an HTTP or HTTPS controller. On TCP or UDP controllers, only \`ip-match\` and \`geo-match\` apply.

| Type | Description |
| --- | --- |
| `ip-match` | Filters traffic based on specific IP addresses or ranges using CIDR. |
| `geo-match` | Filters traffic based on geographic origin of the request. |
| `http-url-match` | Matches requests based on the HTTP URL path, excluding the domain name. |
| `http-method-match` | Evaluates HTTP requests by their method (GET, POST, PUT, etc). |
| `http-header-match` | Matches requests based on HTTP header values. |
| `http-body-match` | Matches requests based on content within the HTTP request body. |

#### Supported Operators

| Operator | Description |
| --- | --- |
| `==` | Equal to |
| `!=` | Not equal to |
| `*=` | Contains |
| `!*=` | Does not contain |
| `^=` | Starts with |
| `!^=` | Does not start with |
| `>` | Greater than |
| `<` | Less than |
| `>=` | Greater than or equal to |
| `<=` | Less than or equal to |

The numeric operators (\`>\`, \`<\`, \`>=\`, \`<=\`) compare numerically and are most useful against header values that carry numbers (e.g., \`Content-Length\`). Other operators perform string comparison.

#### Rule Types

| Type | Behavior |
| --- | --- |
| `allow` | Permits traffic that matches the conditions. |
| `deny` | Disconnects the connection for traffic matching the conditions. |
| `block` | Returns an HTTP 403 Forbidden response for traffic matching conditions. |

#### Customizing the Block Response

When using \`block\`, the HTTP response code can be customized on a per-rule basis using the \`response.http\_code\` field:

```json
{

	"description": "Return 429 for rate-limited paths",

	"type": "block",

	"match": "any",

	"response": {

		"http_code": 429

	},

	"conditions": [

		{ "type": "http-url-match", "operator": "^=", "value": "/api/" }

	]

}
```

If \`response.http\_code\` is omitted, \`block\` returns 403.

#### Evaluation Order

Rules are evaluated in array order. The first rule whose conditions match determines the action taken on the request. There is no implicit default \`allow\` or \`deny\`, if traffic does not match a block it simply follows through with what the load balancer or controller would have done otherwise.

For example: "allow some traffic, then deny everything else" is expressed as a narrow \`allow\` rule first, followed by a broad \`deny\` rule with \`0.0.0.0/0\` and \`::/0\`. The order matters: reversing them would deny all traffic before the \`allow\` rule could fire.

#### Example Firewall Configs

An example use case might be using `http-url-match` and `ip-match` together to constrain traffic from any non-VPN IP into a resource while simultaneously defining a DENY block for all IPs. Approved IPs requesting the resource would be able to connect, while all other traffic would be blocked. This example also uses `sample` to apply the rule to all requests and sets an expiration date.

```json
[
	{
		"description": "Only allow VPN traffic",
		"skip": false,
		"type": "allow",
		"match": "any",
		"sample": 100,
		"expires": "2026-12-31T23:59:59Z",
		"conditions": [
			{
				"type": "http-url-match",
				"operator": "==",
				"value": "/resource-path"
			},
			{
				"type": "ip-match",
				"operator": "==",
				"value": "10.10.24.0/24"
			}
		]
	},
	{
		"description": "Deny all other traffic",
		"skip": false,
		"type": "deny",
		"match": "any",
		"conditions": [
			{
				"type": "ip-match",
				"operator": "==",
				"value": "0.0.0.0/0"
			},
			{
				"type": "ip-match",
				"operator": "==",
				"value": "::/0"
			}
		]
	}
]
```

Using `key` to target a specific HTTP header, combined with `regex` for pattern matching:

```json
[
	{
		"description": "Block requests with suspicious user agents",
		"skip": false,
		"type": "block",
		"match": "any",
		"conditions": [
			{
				"type": "http-header-match",
				"operator": "==",
				"key": "User-Agent",
				"value": "^(curl|wget|python-requests).*",
				"regex": true
			}
		]
	}
]
```

Using `block` to return a 403 for specific IPs, with a contains operator for URL matching:

```json
[
	{
		"description": "Block specific IPs from admin paths",
		"skip": false,
		"type": "block",
		"match": "all",
		"conditions": [
			{
				"type": "ip-match",
				"operator": "==",
				"value": "50.234.222.10"
			},
			{
				"type": "http-url-match",
				"operator": "*=",
				"value": "/admin"
			}
		]
	},
	{
		"description": "Deny suspicious IPv6 address",
		"skip": false,
		"type": "deny",
		"match": "any",
		"conditions": [
			{
				"type": "ip-match",
				"operator": "==",
				"value": "2600:6b4a:223f:93cf:84a1:4afd:9221:8988"
			}
		]
	}
]
```

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
