Skip to content

WordPress admin IP allowlisting: layer architecture across edge, server, plugin

WordPress admin IP allowlisting at one layer leaves gaps. The architecture across CDN, web server, and WordPress that produces consistent enforcement and a single source of truth for the allowed list.

A WordPress admin IP allowlist applied only at .htaccess works when the site has direct origin access but breaks when Cloudflare is added later. An allowlist only at Cloudflare works until somebody finds the origin IP. An allowlist only in the security plugin runs after PHP bootstraps and slows the login form for everyone. None of these are wrong individually; they each have gaps. The architecture below applies the allowlist at every layer with a single source of truth, so an admin’s office IP change updates one record and propagates everywhere.

What’s happening

Admin IP allowlisting is the highest-impact security control for a WordPress site if you can deploy it. It eliminates the brute-force, credential-stuffing, and exploit-probing traffic against the login endpoint by simply not accepting connections from anywhere outside the list. The trade-off is operational: VPN changes, office moves, working from a hotel, on-call from home — all of these need to be in the allowlist or the admin gets a 403 at 3 a.m.

The question is which layer enforces it. Each has properties:

  • CDN (Cloudflare) — runs first, before any of your infrastructure sees the request. Easy to manage if you have many sites with the same allowlist. Vulnerable to origin-IP-bypass.
  • Origin firewall (iptables, security group) — runs at the host level, catches anything that bypassed the CDN. Hard to maintain in a fleet with rotating admin IPs.
  • Web server (.htaccess / nginx) — runs before PHP, returns 403 quickly. Per-site configuration; doesn’t scale to a fleet easily.
  • WordPress plugin (Solid Security, Wordfence) — runs inside WordPress. Easiest to manage from the admin UI; slowest because PHP must boot.

The right architecture is layered: CDN as primary enforcement, web server as secondary in case the CDN is bypassed, WordPress plugin disabled (to avoid the conflicting list). Source of truth is one place — pick one, sync to the others via automation.

How to verify

Inspect what is currently enforcing at each layer:

# CDN: Cloudflare custom rule list (use API or dashboard)
curl -s "https://api.cloudflare.com/client/v4/zones/$ZONE/firewall/rules" \
  -H "Authorization: Bearer $CF_TOKEN" | jq '.result[] | {description, expression, action}'

# Web server: .htaccess in document root and wp-admin
grep -rE "Allow|Require ip" /var/www/html/.htaccess /var/www/html/wp-admin/.htaccess 2>/dev/null

# Plugin: Solid Security allowlist
wp option get itsec-storage | jq '.["banned-users"].white_list' 2>/dev/null

# Plugin: Wordfence whitelist
wp option get wordfence_whitelistedIPs

# Origin firewall (Linux)
sudo iptables -L INPUT -v -n | head -30

Test from a non-allowed IP:

# From a server outside the allowlist
curl -sI https://example.com/wp-login.php
curl -sI https://example.com/wp-admin/

Should return 403 from all paths. If it returns 200 with the WordPress login form, one of the layers is not enforcing the rule.

The fix

Pick the source of truth, configure each layer, automate the sync.

  1. Source of truth: a YAML file in version control. Something like:

    # admin-ip-allowlist.yml
    admins:
      - name: "Office headquarters"
        ips:
          - "203.0.113.0/24"
        owner: "facilities"
      - name: "Alice (work-from-home)"
        ips:
          - "198.51.100.42/32"
        owner: "alice@example.com"
      - name: "On-call VPN"
        ips:
          - "192.0.2.10/32"
        owner: "platform-team"

    Every change to the allowlist is a PR. Reviewer checks that the IP makes sense (not someone’s home IP they did not authorize), the owner is a real person, and the rationale is documented.

  2. Primary enforcement: Cloudflare WAF. Custom rule that allows the IPs in the file and blocks everything else on login paths:

    Expression: (http.request.uri.path eq "/wp-login.php" or 
                 http.request.uri.path matches "^/wp-admin($|/.*$)")
    and not (ip.src in {203.0.113.0/24 198.51.100.42/32 192.0.2.10/32})
    and not http.request.uri.path eq "/wp-admin/admin-ajax.php"
    Action: Block

    Generate this rule from the YAML file with a script that runs on every PR merge:

    # generate-cf-rule.sh
    IPS=$(yq '.admins[].ips[]' admin-ip-allowlist.yml | tr '\n' ' ')
    IP_LIST=$(echo $IPS | tr ' ' ',')
    EXPRESSION="(http.request.uri.path eq \"/wp-login.php\" or http.request.uri.path matches \"^/wp-admin(\$|/.*\$)\") and not (ip.src in {$IPS}) and not http.request.uri.path eq \"/wp-admin/admin-ajax.php\""
    
    curl -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONE/firewall/rules/$RULE_ID" \
      -H "Authorization: Bearer $CF_TOKEN" \
      -d "{\"filter\":{\"expression\":\"$EXPRESSION\"},\"action\":\"block\"}"
  3. Secondary enforcement: web server. Same allowlist, applied at the origin web server in case Cloudflare is bypassed. Generate from the same YAML:

    # generate-htaccess.sh
    echo "<Files \"wp-login.php\">" > /tmp/wp-login-allowlist.txt
    echo "    <RequireAll>" >> /tmp/wp-login-allowlist.txt
    yq '.admins[].ips[]' admin-ip-allowlist.yml | while read ip; do
      echo "        Require ip $ip" >> /tmp/wp-login-allowlist.txt
    done
    echo "    </RequireAll>" >> /tmp/wp-login-allowlist.txt
    echo "</Files>" >> /tmp/wp-login-allowlist.txt
    
    # Deploy to each site's document root via configuration management

    Same for wp-admin/.htaccess. Always include the exception for admin-ajax.php.

  4. Cloudflare-aware origin IP handling. Apache or nginx behind Cloudflare sees the Cloudflare edge IP, not the real client IP, unless the real-IP module is configured:

    # /etc/nginx/conf.d/cloudflare-real-ip.conf
    set_real_ip_from 173.245.48.0/20;
    set_real_ip_from 103.21.244.0/22;
    # ... full Cloudflare IP list
    real_ip_header CF-Connecting-IP;

    Without this, the web-server allowlist rule sees the Cloudflare edge IP and blocks everything because Cloudflare’s IP is not in your admin allowlist.

  5. Disable the WordPress-plugin allowlist. Once CDN and web server enforce, the plugin layer is redundant and adds operational confusion (which list is authoritative?). In Solid Security or Wordfence, leave the brute-force lockout enabled but turn off the IP allowlist functionality. Document this in the runbook.

  6. The “emergency override” path. When an admin’s IP changes and they cannot log in, they need a fast path. The options:

    • Cloudflare Zero Trust with WARP — admin connects through Cloudflare’s tunnel, the egress IP is always in the allowlist. Best for laptops; requires user provisioning.
    • A static IP from a VPN service — admin connects to the VPN, the VPN exit IP is in the allowlist. Works for any device.
    • Out-of-band login — a one-time URL generated via WP-CLI that an admin team member sends when the standard path is blocked. Last resort, requires an admin team that is reachable.

    Pick one and document it. The wrong path is “we will edit the allowlist when someone asks” — that loop is too slow at 3 a.m. and gets bypassed in panic.

  7. Audit quarterly. Owners of each entry confirm they still need access. Stale entries (an ex-employee’s IP that was never removed, an office that closed) get cleaned. The quarterly review is part of the regular ops cadence:

    # List entries with their last-confirmed date
    yq '.admins[] | {name, last_confirmed}' admin-ip-allowlist.yml

    Anything that has not been confirmed in 6 months gets a notification to the owner; anything in 9 months gets removed.

A WordPress site with admin IP allowlisting at CDN and web server has a login endpoint that does not receive credential-stuffing traffic. The work shifts from “responding to login attempts” to “maintaining the allowlist as people change IPs.” Stack Harbor configures the layered allowlist architecture as part of enterprise WordPress hosting onboarding, with the YAML-to-CDN automation and the quarterly review built into the ops cadence. If your admin IP allowlist lives in three places and disagrees with itself, book the consolidation pass.