Docs

Lockouts are keyed to the wrong IP (proxies and CDNs)

5 min readUpdated November 19, 2026

Nahnu Login Shield locks out, blocks and logs by IP address. If it sees the wrong IP address, everything built on it goes wrong. This topic explains why that happens and how to fix it.

The two ways it goes wrong#

Problem A: everyone shares one IP. Your site sits behind a CDN, a reverse proxy or a load balancer, and the plugin is only looking at the address of the proxy. To the plugin, every visitor is the same person. The symptoms:

  • One bad login locks out everybody, including you.
  • The Log tab shows the same IP address on every row.
  • Your own IP never matches the one you see on “what is my IP”.
  • Whitelisting your own IP doesn’t help.

Problem B: the plugin trusts a header it shouldn’t. Proxy headers can be written by anyone who connects to your server directly. If Trust proxy headers is on and your site is not actually behind a proxy that overwrites those headers, an attacker can send a fake header with a different address on every request. The symptoms:

  • Lockouts never seem to happen, even though the Log shows hundreds of failed attempts.
  • The Log shows strange or constantly changing IPs.
  • Someone can get a visitor’s address locked out by pretending to be them.

How Nahnu Login Shield finds the visitor’s IP#

There is one setting for this: Trust proxy headers, on the Lockout tab.

Off (default): the plugin uses the address that connected to your server (REMOTE_ADDR). This is correct when visitors connect to your server directly, with no CDN or proxy in front.

On: the plugin looks for the real visitor address in these headers, using the first valid one it finds:

  1. CF-Connecting-IP (Cloudflare)
  2. True-Client-IP (Cloudflare Enterprise, Akamai)
  3. Fastly-Client-IP (Fastly)
  4. X-Real-IP (nginx)
  5. X-Client-IP (Apache mod_remoteip)
  6. X-Forwarded-For (generic; the first address in the list is used)

If none of these has a valid address, it falls back to the server connection address.

The same IP is used everywhere: lockouts, the blocklist and whitelist, the emergency bypass constant, the early-block rate limit, geo-blocking, the Log, and edge blocking.

Step 1: Find out what the plugin sees#

  1. Find your real public IP. Search “what is my IP” from the device you’re using.
  2. Sign in to your site and open Settings → Login Shield and look at Recent successful logins on the General tab, or at the Log tab, for your last login. Note the IP shown there.
  3. Open Settings → Login Shield → Lockout. When your IP appears in the Active IP lockouts list, it carries a Your IP badge. Check that it matches.
  4. If the addresses differ, the plugin sees the wrong one.

A quick extra test: the lockout message supports an {ip} placeholder. Add it to Lockout message and the lockout screen shows what the plugin sees. Remove it when you’re done.

Step 2: Fix it#

Your site is behind a CDN or proxy, and the plugin sees the proxy’s IP

Turn Trust proxy headers on, then repeat Step 1. This is the usual fix for Cloudflare, Bunny.net, Sucuri, Fastly, nginx proxies, and most hosting firewalls.

Then check that your provider actually sends one of the headers in the list:

ServiceWhat it sends
CloudflareCF-Connecting-IP (always)
FastlyFastly-Client-IP
Akamai / Cloudflare EnterpriseTrue-Client-IP
nginx or Apache reverse proxyUsually X-Real-IP or X-Forwarded-For; you may need to enable it in the proxy configuration
Bunny.netX-Forwarded-For (check in your Bunny pull zone settings)
Hosting-level firewalls and load balancersUsually X-Forwarded-For; ask your host

If your provider uses a header name that isn’t in the list, the plugin can’t see the real IP. Ask the provider to also send X-Forwarded-For, or ask us to support it (see Protect any other form for how to request a feature).

Your host already restores the real IP

Many hosts and server stacks fix this before WordPress runs (for example mod_remoteip on Apache, or real_ip on nginx). Then the server connection address already is the visitor, and Trust proxy headers should stay off. Turning it on there is unnecessary and adds risk.

If Step 1 shows the right IP with the setting off, leave it off.

Your site is not behind a proxy at all

Make sure Trust proxy headers is off. If it’s on, anyone can fake an address (Problem B).

You use a proxy and the origin server is reachable directly

Even with the setting on, an attacker who finds your origin server’s real address can bypass the CDN and send fake headers straight to it. To close this:

  • Restrict your origin server so it accepts web traffic only from your CDN’s IP ranges (in your firewall or host panel).
  • Or use the CDN’s authenticated origin pulls or a secret header.

This is a server and CDN task, not a plugin setting.

Two proxies in a row (for example Cloudflare, then a load balancer)

Cloudflare’s CF-Connecting-IP is checked first, so it is used as long as it reaches your server. If you also put another proxy in front of WordPress that strips unknown headers, make sure it passes CF-Connecting-IP through.

Step 3: Clean up after the fix#

  1. Unlock and unblock the wrong entries. Lockouts and blocks stored against the proxy’s IP are still in place. On the Lockout tab, unlock the proxy’s IP, and remove it from the blocklist if it ended up there. See Unlock an IP.
  2. Check the whitelist. Whitelist the visitor’s real IP (yours), not the proxy’s. A whitelisted proxy IP would whitelist everyone.
  3. Check the bypass line in wp-config.php (NAHNLS_BYPASS_IP). It must hold your real IP, not the proxy’s.
  4. Check the edge block lists at Bunny.net and Cloudflare for wrong entries.
  5. Watch the Log for a day. Different visitors should now show different IP addresses.

What about geo-blocking?#

Geo-blocking uses the country headers your CDN adds (for example CF-IPCountry), and it can fall back to an IP lookup service. That part is separate from the IP header, but a wrong IP can cause wrong country results in the fallback. Fix the IP first. See Supported CDN country headers.

Was this helpful?

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only