Restrict a path with a password or an IP allow list
Close a staging site, an admin area or a private folder at the edge: on a delivery rule, ask for a username and password, let only the IP addresses you list through, or both. Requests that do not pass are answered by the edge and never reach your server.
Cache, security, WAF, and purge
Restrict a path with a password or an IP allow list
Close a staging site, an admin area or a private folder at the edge: on a delivery rule, ask for a username and password, let only the IP addresses you list through, or both. Requests that do not pass are answered by the edge and never reach your server.
Related topics
Other ways to control who reaches your site.
Block traffic by ASN and by country
Account-wide lists for countries, networks and IP addresses.
For an IP allow list: the public IP addresses or ranges your team connects from.
Step-by-step guide
1
Choose the path
The protection applies to the paths of one rule.
Open the rule, or add one, on the Rules tab of Domains & Rules.
Under When a request matches, set Path to Starts with and type the path, for example /admin.
Expected result: The rule shows the path it serves.
2
Turn on the protection
A password, an IP allow list or both.
Turn on Ask for a username and password and enter both.
Turn on Only allow these IP addresses and add your addresses or ranges.
Save, then open the path from a private window and from another network.
Expected result: The browser asks for the password; from an address not on the list the path answers 403 Forbidden.
Use cases
You want /admin or a staging site open only to your office and your team, without changing the application.
Quick workflow
Open Domains & Rules and go to the Rules tab. Open the rule for the path, or add one: under When a request matches, set Path to Starts with/admin. Is exactly, File type is and Regular expression (advanced) are there too; All paths covers the whole site.
For a password: under Password protection, turn on Ask for a username and password and enter a Username and a Password of 8 to 128 characters.
For an IP list: under IP allow list, turn on Only allow these IP addresses and enter one IPv4 or IPv6 address or CIDR range (such as 198.51.100.0/24) per line, up to 100.
If the same site also has a rule for the other protocol (HTTP or HTTPS), tick the option to protect that rule too with the same username and password.
Save the rule. When the change is live, open the path in a private browser window to check.
Checks
Without the right username and password the edge answers 401 and the browser asks again. After repeated wrong passwords from one address, the edge answers 429 for a few minutes.
With an IP allow list, other addresses get 403 Forbidden on that rule's paths. With both, other addresses get 403 before any password prompt.
The password is stored only as a hash and is never shown again. Use Change password to set a new one and Remove password to open the path again. Each rule has one username and password.
The edge checks the password itself and removes it from the request before forwarding to your server.
The protection covers the requests that rule serves. If another rule answers part of them first (a longer prefix, an exact path or a pattern), the panel points it out: add the same protection to that rule too.
Addresses on the account's IP block list stay blocked, even when they are on a rule's allow list.
Account-wide image optimization skips the paths of a rule with a password or an IP allow list, so images there are served as they are.
Frequently asked questions
Can I let a whole office network in?
Yes. Enter the network as a CIDR range, for example 198.51.100.0/24 or an IPv6 range such as 2001:db8:1234::/48.
How do I protect a whole staging site?
Choose All paths on the rule that serves the staging site and turn on the password, the IP allow list or both.
Can I give different people different passwords?
Each rule has one username and password. For areas that need separate access, use a separate rule for each path, or let your team in by address with the IP allow list.
How do I block a country or a network on the whole site?
Use the account-wide lists on the Security tab: Block IP addresses, Block countries and Block networks (ASN). See Block traffic by ASN and by country.