База знаний

Restrict /admin/ to trusted IPs

Эта статья есть на вашем языке: Как открыть /admin/ только для доверенных IP

Restrict the administration area by IP while keeping the rest of your website public.

Before you start

The site must use WebShield, have rules enabled, and have spare rule capacity. The editor must offer Адрес (Path), IP, and Блокировать (Block). Available controls depend on your plan and protection server capabilities. Replace example.com and 198.51.100.27/32 with your domain and actual public office IP. Include every trusted exit address, including IPv6 if used.

Confirm that your administration area uses /admin/. Keep the WebShield panel open for rollback. The sitewide access allowlist restricts the whole website and does not fit this task. Rules controls currently retain Russian labels in the English panel.

Steps

  1. Open WebShield → example.com → Правила → Добавить правило (Rules → Add rule). Name it Admin: office only.
  2. Under Что делать (What to do), select Блокировать (Block).
  3. In the first group, set Адрес (Path) to Начинается с (starts with) /admin/.
  4. Click + Добавить условие (Add condition) in that group. Set IP to Не в списке (not in list), value 198.51.100.27/32. For several trusted addresses, use + Несколько значений (Multiple values), one IP/CIDR per line.
  5. Click + Добавить группу ИЛИ (Add OR group). Set Адрес Равно (equals) /admin, then repeat IP Не в списке with the same trusted addresses. The /admin/ prefix does not cover /admin without its trailing slash.
  6. Review the preview. The first group must match /admin/ and its subpages from untrusted IPs; the second must match /admin from those IPs. Both groups need the IP condition.
  7. Click Сохранить правило (Save rule). An earlier matching ordinary rule can intercept the request; use Выше (Up) to move this restriction if necessary. Allow synchronization.

Адрес (Path) excludes the domain and query string: https://example.com/admin/?tab=users uses /admin/. Avoid Начинается с with /admin, which also matches /administrator.

Rule for /admin/ and /admin excluding a trusted IP

Check the result

In Проверить на примере запроса (Check a sample request), test /admin/login and /admin: the trusted IP should not match; another IP should match. / should not match from either address. The simulator checks conditions, not actions or the full rule chain. It can report Недостаточно данных для проверки (Insufficient data), including for IPv6.

Then test live access: the office can open admin pages, another network is blocked, and both can open the homepage. Not matching this rule does not bypass application login or other restrictions.

Статья была полезна?