Docs

The early-block mu-pluginUpdated

6 min readUpdated November 19, 2026

The early-block mu-plugin is an optional add-on that makes Shield stop bad traffic sooner. Instead of waiting for WordPress and every plugin to load, it turns away locked-out IPs and login floods almost immediately. That saves your server a lot of work during an attack.

It is off by default. Nothing is installed until you click a button.

The Early Block mu-plugin box on the General tab, marked Not installed, with a description of what the file does and an Install early-block mu-plugin button.

What is a “mu-plugin”?#

A mu-plugin (“must-use plugin”) is a small PHP file in a special folder, wp-content/mu-plugins. WordPress loads these files early, before normal plugins. They don’t appear on the regular Plugins screen’s active list and can’t be deactivated from there. Shield’s file is called nahnls-early-block.php.

Why use it#

Normally a blocked request still makes WordPress load fully (themes, plugins, database setup) before Shield can say no. During a brute-force attack with thousands of requests, that adds up and can slow your site down.

The mu-plugin does the checks first. It only looks at login traffic: wp-login.php, your custom login address if you set one, xmlrpc.php, and WooCommerce login forms. It runs these checks, cheapest first:

  1. Locked-out IPs. If an IP is already locked out by Shield, the mu-plugin turns it away at once. Shield keeps one small file per locked IP for this, so the check needs no database query. A normal lockout gets a “Too many attempts” page (429). An IP caught by a honeypot username gets an “Access Restricted” page (403).
  2. Rate limit. A single IP can make up to 20 login requests per minute. After that it gets a “429 Too many requests” reply and is asked to wait 60 seconds. The count is kept in a small file on your server, not in the database.
  3. Repeat offenders. An IP that goes over the rate limit in three separate minutes, or reaches three times the limit within one minute, is handed to Shield as a real lockout. It is then locked out for your normal lockout time and, if you use edge blocking, pushed to Bunny.net or Cloudflare.
  4. Blocked IPs. IPs on your manual blocklist get a 403. The event log records one row per IP per minute.
  5. Blocked countries. After Shield has refused a visitor from a blocked country, the mu-plugin refuses that IP for the next 15 minutes without looking the country up again.
  6. XML-RPC. If you’ve disabled XML-RPC in Shield, requests to it get a 403.
  7. Hidden login page. If you use a custom login URL, direct requests to wp-login.php get a bare 404 page or the home-page redirect, without loading your theme.
  8. Strict JavaScript check. If you turned on Strict under Require JavaScript, a login without the JavaScript marker gets a 403. See “The JavaScript presence check”.

Everything else on your site loads as usual. Public pages, wp-admin and the REST API (/wp-json/) are never touched by the mu-plugin.

What it doesn’t do#

The mu-plugin doesn’t replace Shield. It only covers the quick checks listed above. The rest still runs in the main plugin: counting failed attempts, starting lockouts, CAPTCHA, 2FA, country lookups and a custom redirect address for the hidden login page.

Install it#

  1. Go to Settings → Nahnu Login Shield and open the General tab.
  2. Find the Early Block mu-plugin box at the top. It shows its state: Not installed, Installed, or Installed (outdated).
  3. Click Install early-block mu-plugin.
  4. A green message confirms it: “Early-block mu-plugin installed. Locked-out IPs and disabled XML-RPC requests are now rejected before WordPress fully loads.”

Once installed, the box is replaced by a row labelled Early Block mu-plugin with a green tick and the file’s location.

The Early Block mu-plugin row on the General tab showing a green Installed tick, a Remove mu-plugin button and the file location wp-content/mu-plugins/nahnls-early-block.php.

If the button isn’t there

If WordPress can’t write to the mu-plugins folder, Shield hides the button and shows a note instead. You can install it by hand:

  1. Copy the file nahnls-early-block.php from the Shield plugin folder into wp-content/mu-plugins/. Create that folder if it doesn’t exist.
  2. Reload the General tab. It should now say Installed.

To turn it off again, delete that file.

Keeping it up to date#

The mu-plugin is a copy of a file inside Shield. From version 1.0.19, Shield refreshes that copy for you. The first time your site loads after a plugin update, an installed mu-plugin is replaced with the new version.

  • Shield only refreshes a copy you installed. It never installs the file by itself.
  • This also happens when you update to 1.0.19 from an older version. You don’t need to click anything.
  • If WordPress can’t write to the mu-plugins folder, the General tab shows Installed (outdated) and an Update mu-plugin button. Click it, or copy the file by hand as described above.

Don’t edit the copy by hand: the next update overwrites your changes.

Remove it#

Click Remove mu-plugin on the General tab (it asks you to confirm). From then on, locked-out IPs are rejected by the main plugin, as normal, with no loss of protection beyond speed. The file is also removed if you deactivate or delete Shield.

Settings that affect it#

  • Trust proxy headers (Lockout tab). The mu-plugin uses the same rule as the main plugin to work out the visitor’s IP. If you’re behind a CDN or proxy, turn this on or every visitor will look like the same IP. With it off, the rate limit would apply to everyone at once, and the mu-plugin does not turn rate-limit hits into lockouts, because it would be locking out the proxy. See “Lockouts are keyed to the wrong IP (proxies and CDNs)”.
  • Whitelisted IPs (Lockout tab). Whitelisted IPs are never rate limited, locked out or blocked by the mu-plugin.
  • NAHNLS_BYPASS_IP (wp-config.php). IPs listed here are never rate limited or turned away by the mu-plugin.
  • Blocked IPs (Lockout tab). The mu-plugin refuses these IPs on login requests.
  • Disable XML-RPC (Access tab). The mu-plugin enforces this setting early. See “Disable XML-RPC”.
  • Custom login URL (General tab). The mu-plugin answers direct wp-login.php requests when the redirect is set to the 404 page or the home page. See “Custom login URL”.
  • Require JavaScript → Strict (General tab). See “The JavaScript presence check”.
  • Your own server and local addresses (like 127.0.0.1) are never blocked.

Good to know#

  • Files it uses. The mu-plugin keeps its data in wp-content/uploads/nahnu-login-shield/: rate-limit counters in ratelimit/ and one small file per locked-out IP in blocks/. Both folders have a protective .htaccess and an empty index.php so they can’t be browsed. File names are a hash of the IP, not the IP itself. Old files are cleaned up once a day. Uninstalling Shield deletes the folders.
  • Shared hosting. If your host doesn’t allow you to write to wp-content/mu-plugins, use the manual copy or ask your host.
  • Caching. The mu-plugin sends no-store on its block pages, so they aren’t cached.
  • Block pages. Pages shown by the mu-plugin use one plain design. The country-block page shows your own heading, message and contact email.
  • Testing. To see the rate limit, reload wp-login.php more than 20 times in a minute. Do this from an IP that’s not whitelisted or in NAHNLS_BYPASS_IP. You should get a plain “Too many requests. Please slow down.” message.

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