Opens in a new tab

Access Control

Access Control features allow you to restrict who can access your website based on IP addresses, geographic location, and specific URI paths.

IP Whitelist

What it is: A list of IP addresses that are always allowed to access your site, bypassing all other security checks.

Use cases:

  • Your office IP address
  • Admin/developer IP addresses
  • Trusted partner IPs
  • Monitoring services

Format: One IP address per line, supports CIDR notation

192.168.1.100
203.0.113.0/24
2001:db8::1

Important: Whitelisted IPs bypass WAF, rate limiting, and geographic restrictions. Only whitelist IPs you fully trust.

IP Blacklist

What it is: A list of IP addresses that are always blocked from accessing your site.

Use cases:

  • Known attacker IPs
  • Spam sources
  • Abusive users

Response Options:

  • 403 Forbidden: Show “Access Denied” message
  • 404 Not Found: Pretend the site doesn’t exist
  • 451 Unavailable: Legal/compliance blocking

Format: Same as whitelist – one IP per line, supports CIDR notation

Geographic Access Control

What it is: Block or allow access based on the visitor’s country.

Block Mode: Select countries to block (all others allowed)

Allow Mode: Select countries to allow (all others blocked)

Use cases:

  • Comply with data privacy regulations (GDPR)
  • Reduce spam from specific regions
  • Restrict service to specific countries

Important: Geographic blocking is based on IP geolocation databases which are ~95% accurate but not perfect.

Page Protection Rules

What it is: Apply security actions to specific URI patterns – IP restrictions, rate limiting, or CAPTCHA challenges.

Use cases:

  • Protect /admin area to office IPs only
  • Rate limit /api/* endpoints to prevent abuse
  • Add CAPTCHA to /wp-login.php for brute-force protection
  • Lock down sensitive pages with custom response codes

Creating a Protection Rule

  1. Enable the rule with the toggle
  2. Rule Name: Give it a descriptive name (e.g., “Admin Area Protection”)
  3. URI Pattern: Specify what to protect
    • Wildcard: /admin/* (protects all admin pages)
    • Exact: /api/internal (protects specific path)
    • Prefix: /api* (matches /api, /api/, /api/v1, etc.)
  4. Action: Choose the protection method:
    • IP Restriction: Block/allow based on IP addresses
    • Rate Limiting: Limit requests per minute per IP
    • Captcha Challenge: Require proof-of-work verification before access
    • Geographic Access: Block/allow based on visitor’s country

IP Restriction Action

When you choose IP Restriction:

  1. Whitelisted IP Groups: Select reusable IP groups
  2. Additional IPs: Add specific IPs for this rule only
  3. Inherit Global Whitelist: Include IPs from global whitelist
  4. Response Action: What to return to blocked users
    • 403 Forbidden: Standard “Access Denied”
    • 404 Not Found: Stealth mode (hide resource)
    • 451 Unavailable: Legal/compliance blocking
    • 503 Service Unavailable: Maintenance mode
    • CAPTCHA: Proof-of-work challenge

Example: Protect admin area

Rule Name: Admin Area Protection
URI Pattern: /admin/*
Action: IP Restriction
Whitelisted IPs: 203.0.113.45
Inherit Global Whitelist: Yes
Response Action: 404 Not Found

Rate Limiting Action

When you choose Rate Limiting:

  1. Requests Per Minute: Maximum requests per IP (1-10,000 for Free/Advanced)
  2. Allow Global Whitelist to Bypass: Let trusted IPs bypass the limit

Response: Always returns HTTP 429 (Too Many Requests) when limit exceeded.

Example: Protect login page

Rule Name: Login Brute-Force Protection
URI Pattern: /wp-login.php
Action: Rate Limiting
Requests Per Minute: 10
Allow Global Whitelist to Bypass: Yes

See the Rate Limiting guide for more details.

Captcha Challenge Action

When you choose Captcha Challenge:

  1. Allow Global Whitelist to Bypass: Let trusted IPs bypass the captcha

Response: Redirects to captcha challenge page. After solving, user is returned to original URI.

Use Cases:

  • Brute-force protection for login pages (/wp-login.php)
  • Bot protection for registration forms
  • Prevent automated scraping of sensitive content
  • Add friction to API abuse without hard blocking

Example: Protect login page

Rule Name: Login Captcha Protection
URI Pattern: /wp-login.php
Action: Captcha Challenge
Allow Global Whitelist to Bypass: Yes

How it works:

  1. User requests protected URI (e.g., /wp-login.php)
  2. Caddy redirects to captcha challenge page
  3. User solves proof-of-work challenge
  4. User is redirected back to original URI
  5. Session expires after use (one-time verification)

Geographic Access Action

When you choose Geographic Access:

  1. Geographic Access Mode: Choose whitelist or blacklist mode
    • Whitelist Mode: Only allow selected countries (block all others)
    • Blacklist Mode: Block selected countries (allow all others)
  2. Allowed/Blocked Countries: Select countries from the list
  3. Response Status Code: HTTP status returned to blocked visitors
    • 403 Forbidden: Standard access denied
    • 404 Not Found: Stealth mode
    • 451 Unavailable For Legal Reasons: Legal/compliance blocking (recommended)
    • 503 Service Unavailable: Maintenance mode
    • 410 Gone: Resource permanently removed
  4. Block Message: Custom message shown to blocked visitors

Use Cases:

  • Restrict specific content to certain regions (/eu-only/* → whitelist EU countries)
  • Block high-risk countries from admin areas (/admin/* → blacklist specific countries)
  • Comply with regional data regulations (GDPR, CCPA)
  • Reduce spam/abuse from specific regions on API endpoints

Example: Restrict admin to US/CA only

Rule Name: Admin Geographic Restriction
URI Pattern: /admin/*
Action: Geographic Access
Mode: Whitelist
Allowed Countries: US, CA
Response Status Code: 451 Unavailable For Legal Reasons
Block Message: This content is not available in your region

Example: Block high-risk countries from login

Rule Name: Login Geographic Protection
URI Pattern: /wp-login.php
Action: Geographic Access
Mode: Blacklist
Blocked Countries: CN, RU, KP
Response Status Code: 403 Forbidden
Block Message: Access denied from your location

Important Notes:

  • Geographic blocking uses IP geolocation databases (~95% accurate)
  • VPN users can bypass geographic restrictions
  • No country limit per page rule (only limited by number of rules in your plan)
  • Global geographic access control still available for site-wide blocking

Best Practices

  1. Always whitelist your own IP before enabling restrictions
  2. Test from a non-whitelisted IP to verify blocking works
  3. Use 404 for stealth – attackers won’t know the resource exists
  4. Document your rules – use descriptive rule names
  5. Monitor logs – check for legitimate users being blocked

Troubleshooting

I’m locked out of my own site

  • Contact support to temporarily disable access control
  • Always whitelist your IP before enabling restrictions

Legitimate users are being blocked

  • Check if their country is in the blocked list
  • Verify their IP isn’t in the blacklist
  • Check Page Protection rules for conflicts

Geographic blocking isn’t working

  • Verify the feature is enabled
  • Check that countries are selected
  • Note: VPN users may bypass geographic restrictions

Frequently Asked Questions