Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions calico-enterprise/threat/web-application-firewall.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,38 @@ kubectl replace -f ruleset.configmap.yaml

Read more about the order of execution for plugins here: https://coreruleset.org/docs/4-about-plugins/4-1-plugins/

#### GeoIP-based rules

WAF includes an embedded city-level geolocation database, enabling you to write rules that filter traffic
based on geographic origin. You can use the `@geoLookup` operator along with `GEO` variables like
`GEO:COUNTRY_CODE` in your custom rules.

**Example: Block traffic from a specific country**

```bash
# Look up the geographic location of the client IP
SecRule REMOTE_ADDR "@geoLookup" "phase:1,id:155,nolog,pass"

# Deny the request if the country code matches
SecRule GEO:COUNTRY_CODE "@streq RU" "phase:1,id:157,deny,msg:'Access from this country is not allowed'"
Comment on lines +331 to +336
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both examples use the same rule id (id:155) for the @geoLookup rule. The note below suggests combining these examples, but combining them as written would create duplicate rule IDs and can cause the WAF config to fail to load or behave unpredictably. Use a single @geoLookup rule and ensure all rule IDs are unique (and update the text about combining accordingly).

Copilot uses AI. Check for mistakes.
```

**Example: Deny traffic from IPs not found in the GeoIP database (e.g. private IPs)**

```bash
SecRule REMOTE_ADDR "@geoLookup" "phase:1,id:158,nolog,pass"

# &GEO equals 0 when the IP was not found in the database
SecRule &GEO "@eq 0" "phase:1,id:159,deny,msg:'Failed to look up IP'"
```

:::note

You can combine both rules to deny unknown IPs while also blocking specific countries. If you only want to
block certain countries but allow private/unknown IPs through, omit the `&GEO "@eq 0"` rule.

:::

## View WAF events

### Security Events
Expand Down