Geo-blocking without a CDN
You don’t need Cloudflare or any other CDN to use geo-blocking. If your site has no CDN, Shield looks up each visitor’s country through an IP lookup service instead. It works the same way for your visitors. The difference is where the country comes from, and a few trade-offs.
Set it up#
- Go to Settings → Login Shield and open the Geo tab.
- Turn on Block login form by country.
- Under Country detection source, turn Trust CDN geo headers off. (See “Why switch the headers off” below.)
- Under IP lookup API, choose a service:
- freeipapi.com: free, no account or key needed. Limited to 60 requests per minute.
- ipinfo.io Lite: free, but you must create an account at ipinfo.io and paste your token into the IP API key field.
- Choose IP API cache time. The default is 24 hours.
- Under Country blocklist, choose Use a custom list at login and pick your countries.
- Choose your Fallback: Allow or Block (see below).
- Click Save geo settings.

What happens on each login visit#
The first time an IP reaches your login page, Shield sends that IP to the lookup service and waits up to 3 seconds for the country. It then remembers the answer for the cache time you set, so the same IP isn’t looked up again until the cache runs out. Shield checks the country against your blocklist and either shows the login form or the “Access restricted” screen.
So the first visit from a new IP may load a little slower than usual. Later visits don’t.
Why switch the headers off#
With no CDN, nothing in front of your server controls what a visitor sends. Someone can add a fake header such as CF-IPCountry: US to a request. If Trust CDN geo headers is on, Shield would believe it and show them the login form even if they’re in a blocked country.
Turn Trust CDN geo headers off so Shield ignores those headers and uses the lookup service only.
The Fallback setting#
If the lookup fails, Shield doesn’t know the country. This can happen if:
- the service is down or too slow (over 3 seconds),
- the service doesn’t recognise the IP,
- your server can’t make outgoing web requests,
- you’re using ipinfo.io with a missing or wrong token,
- you’ve hit the free limit.
Fallback then decides what happens:
- Allow (default): the login form is shown. Your site stays usable, but a visitor Shield couldn’t look up isn’t blocked.
- Block: the login form is hidden. This is stricter, but if the lookup service has a problem, everyone is blocked, including you, unless your IP is whitelisted.
A failed lookup is also remembered for the cache time. If the service had a short outage, an IP that failed may keep getting the Fallback treatment until the cache expires.
Make sure the IP Shield sees is right#
The lookup is only useful if Shield knows the visitor’s real IP. If your host puts your site behind a proxy or load balancer, Shield might see the proxy’s IP, and then every visitor looks like they’re in the proxy’s country. If that sounds like your site, check Trust proxy headers on the Lockout tab. See “Lockouts are keyed to the wrong IP (proxies and CDNs)” in the Troubleshooting section.
Privacy: visitor IPs leave your site#
When you use a lookup service, each new IP that reaches your login page is sent to that company’s server. If you serve visitors in regions with strict privacy laws, you may need to mention this service in your privacy policy. A CDN header avoids this. See “External services Shield can contact” in the Privacy and Data section.
The API key you enter is stored in your site’s settings and isn’t shown again after you save. The field shows that it’s set instead.
Limits to know about#
- IP-to-country lookups are not perfect. Newly assigned addresses, mobile networks and satellite connections can be placed in the wrong country.
- VPNs and proxies get around geo-blocking. A visitor on a VPN in an allowed country looks like they’re there.
- Your server must be able to reach the service. Some hosts block outgoing connections. If so, every lookup fails and the Fallback applies.
- Free plans have limits. On freeipapi.com’s free plan, a very busy login page (for example during a bot attack from many IPs) could exceed the limit. Lookups then fail and the Fallback decides. If that’s a concern, use ipinfo.io’s token plan, or put the site behind a CDN.
- Geo-blocking is one layer. It works best next to lockouts, the IP blocklist and 2FA.
Switching to a CDN later#
When you add a CDN, turn Trust CDN geo headers on and make sure your CDN sends a supported header. See “Supported CDN country headers”. Shield will use the header first and the lookup service only if no header is found.
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!