Geo blocking
Geo blocking is configured per proxy host, and per L4 host. It needs MaxMind GeoLite2 databases, which CPM can keep updated for you.
Rule types
Section titled “Rule types”| Type | Example | What it matches |
|---|---|---|
| Country | DE |
ISO 3166-1 alpha-2 country code |
| Continent | EU |
AF, AN, AS, EU, NA, OC, SA |
| ASN | 24940 |
Autonomous System Number |
| CIDR | 91.98.150.0/24 |
An IP range |
| IP | 91.98.150.103 |
One exact address |
Allow beats block
Section titled “Allow beats block”Rules are either block or allow, and allow rules take precedence. That lets you block an entire continent, then allow the two ASNs or addresses that should still get through.
Fail-closed
Section titled “Fail-closed”If the real client address cannot be determined - behind a trusted proxy that sent no usable client-IP header, say - fail-closed mode rejects the request rather than letting it past. It is off by default, since for most deployments a misconfigured proxy should not take the site down. Turn it on when the block list is a security control rather than a nuisance filter. It is an HTTP option: an L4 host has no headers to trust.
Responses
Section titled “Responses”A blocked HTTP request gets a status code and body you choose. At layer 4 there is nothing to answer with, so the connection is closed.
Trusted proxies
Section titled “Trusted proxies”If CPM sits behind another proxy, the client address it sees is that proxy’s. Settings → Network → Trusted Proxies tells Caddy which addresses to trust and which header carries the real client IP, so geo rules match the visitor rather than your load balancer. While the global geo-blocking trusted-proxy list is empty, this list can seed it. Hosts in merge mode inherit that list, so the two cannot silently disagree.
Getting the databases
Section titled “Getting the databases”-
Register for a free account at maxmind.com.
-
Generate a licence key with
GeoLite2-Country,GeoLite2-CityandGeoLite2-ASNpermissions. -
Open Settings → Geo-blocking → GeoIP databases, tick Use GeoIP, and enter the account ID and key.
That is the whole setup. The controller downloads the databases, checks MaxMind for updates once a day by default, and every agent fetches them from it.
If the controller cannot reach MaxMind, upload the .mmdb files under Upload a database in the
same block. CPM opens each one and checks its edition before it replaces anything.
Offline mode turns the downloads off; uploads still work.
With Use GeoIP off, the host forms still show the geo blocking fields, marked GeoIP off, and no country is recorded against an event.