Prod geoblock: raise cacheSize and fail open when geojs.io is unreachable #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two problems in the
geoblockmiddleware inconfig.yml. Both were found and fixed on the dev host (prkl10) while building the WordPress migration stack; prod still carries them.1. Site goes down if geojs.io does (availability risk)
Every non-cached request makes a live call to
https://get.geojs.io/v1/ip/country/{ip}with a 750ms timeout. When that call fails or times out, the country is "unknown", and with this set tofalsean unknown country is blocked.So if geojs.io is down, slow, or rate-limits us, every visitor is blocked, including US visitors. A free third-party service we do not control sits in the critical path of every request to every geoblocked site on this host, with no fallback and no degraded mode.
2.
cacheSize: 25is far too small (latency + rate-limit risk)Only 25 IPs are remembered, so on any site with real traffic nearly every request becomes a fresh API call. That adds up to 750ms before WordPress even starts, and generates large call volume against a free API that may throttle us — which then triggers problem 1.
Fix
With these, a geojs.io outage degrades to "geoblocking temporarily ineffective" instead of "site down". CrowdSec still blocks actual attackers, so the security posture does not depend on geoblock being up. 5000 cached entries is negligible memory and turns the API call into a rare event.
Gotcha: a restart is required
config.ymlis bind-mounted as a single file. Editing it with anything that writes atomically (temp file + rename, which most editors do) creates a new inode, so the container keeps seeing the old file and Traefik'swatch: truenever fires. This is silent — the config on disk looks correct while the running container uses the old values.After editing, verify from inside the container:
Worth considering mounting the directory instead of individual files to avoid this class of problem.
Verification
Expect
status=enabled,error=none, and the new values.Related, not fixed here
apiTimeoutMs: 750— less critical once failures fail open, but still 750ms of worst-case added latency per uncached visitor.traefik.pkartchner.comcurrently resolves to the dev host (38.78.244.119 viaprkhome), not prod, so prod's dashboard is not reachable at its own hostname.config.ymlis now gitignored on dev, withconfig.yml.examplecommitted in its place.