ProxyAuth / Security

redirect_protect, completely: from a maintenance page to a real access-control layer

ProxyAuthSecurity / Access controlUpdated on 2026-09-18

redirect_protect began as the obvious thing: everyone not on an IP list gets a maintenance page. That part has not changed. What has grown around it turns it into a way to let one small endpoint your backend already has drive real access decisions — down to a single element on a page — without ProxyAuth understanding your application’s authentication at all.

Where it runs

After the IP blocklists and ACME challenge handling, before authentication is considered. It does not ask who is logged in, but who reaches the real content right now. Set on a vhosts: group, it covers every route under it; on a single route, only that prefix.

Because ACME handling runs first, a vhost in maintenance keeps renewing its certificate.

Layer 1 — who gets through

vhosts:
  - vhost: ["app.example.com"]
    redirect_protect:
      allow_ip:
        - "203.0.113.42"      # you
        - "10.0.0.0/8"        # the office
      path: "/var/www/maintenance/index.html"

Only allow_ip reaches the normal content; everyone else gets path with a 503. IPv4 and IPv6 CIDRs work. The file is read fresh on every request and never cached, so editing it takes effect immediately, and it can be any content type ProxyAuth recognises. An empty allow_ip means maintenance for everyone — no catch-all to spell out.

Since routes.yml reloads live, entering and leaving maintenance needs no restart.

Fetched lists

redirect_protect:
  allow_url_ips:
    source: "https://vpn.example.com/egress-ips.txt"
  deny_url_ips:
    source: "https://example.com/known-compromised.txt"
  path: "/var/www/maintenance/index.html"

Both take the same source object as ip_blocklists — source, name, csv, csv_column — with the same parser (gzip by magic bytes, comments, CIDRs), refreshed every redirect_protect_refresh_interval_secs (global, default 3600; 0 fetches once at startup). A failed fetch keeps the last good result rather than going empty.

allow_url_ips is merged with allow_ip. deny_url_ips is checked first and always wins: “the whole office range, except the one machine known to be compromised”.

Layer 2 — where a blocked visitor lands

redirect_protect:
  allow_ip: ["203.0.113.42"]
  target: "http://status.internal.example.com"
  path: "/var/www/maintenance/index.html"   # fallback

target proxies the blocked request — method, headers and body — to another service and returns its response. It is tried first; path is used only if reaching target fails (connection error, timeout, invalid URL). The fetch is bounded by backend_timeout.

Layer 3 — asking the backend

paths adds path-scoped gates on top of the IP check — not a replacement for it. Each entry requires a valid backend session, verified by asking the backend itself:

redirect_protect:
  allow_ip: ["203.0.113.0/24"]
  redirect_url: "https://git.example.com/user/login"
  paths:
    - regex: '^/[^/]+/[^/]+/src(/.*)?$'
      check_path: "/notifications"
      type_return: "status_code"
      expected_status: 200

For a request whose path matches regex, ProxyAuth sends a request to the route’s own backend at check_path, forwarding the original Cookie header unchanged, and reads the answer:

FieldMeaning
regexsearched anywhere in the path; anchor with ^…$ for an exact match
check_pathalways appended to the route’s target, whatever matched
type_returnstatus_code (default) or json
expected_statuswith status_code: exact code required; unset accepts any 2xx
expected_fieldwith json: top-level field to read — required, or the rule never passes
expected_valuewith json: value to compare against its string form; unset means presence is enough

status_code is usually enough: a session-protected endpoint returns 401 or redirects when logged out, neither of which is 2xx. Use json when the logged-out answer is also a 2xx:

paths:
  - regex: '^/billing(/.*)?$'
    check_path: "/api/user"
    type_return: "json"
    expected_field: "authenticated"
    expected_value: "true"

On failure, redirect_url — shared by all paths rules — sends a real 303 See Other. Without it, the failure falls through to the same target/path resolution as the IP check. redirect_url never applies to the IP check itself.

The probe has its own tight time budget, separate from backend_timeout: it runs ahead of every matching request.

Why this is worth sitting with

ProxyAuth never needs to know how your backend authenticates — session cookies, JWTs, a custom header, OAuth. It needs one endpoint that already answers “is this session valid”: /api/user, /whoami, or any authenticated page that behaves differently when logged out. This works unchanged on an OIDC vhost, where ProxyAuth’s own cookie is not the authority in the first place.

The answer is also authoritative and current: it is what the backend says right now, not an assumption drawn from a cookie’s shape.

Layer 4 — hiding one element

redirect_protect:
  paths:
    - regex: '^/dashboard(/.*)?$'
      check_path: "/api/user"
      type_return: "json"
      expected_field: "role"
      expected_value: "admin"
      hidden_blocks:
        - html_tag: '<div id="admin-panel" class="widget">'
          fallback_html: "<p>You don't have permission to view this.</p>"
  • html_tag is the exact opening tag copied from the page — attributes, order, quoting. Any tag name works. ProxyAuth finds the matching closing tag itself, skipping nested elements of the same name. If the literal text is absent, the rule is a silent no-op.
  • fallback_html replaces the element when the check fails; without it, the element is removed.

Two rules make this behave predictably:

Adding one hidden_blocks rule changes the entry’s job. Without it, a failed check gates the whole path. With it, the request always goes through and the check decides what to hide in the response.

It requires tag_proxyauth: true on the route. hidden_blocks runs on the same response-scanning pass as {{ }} tag substitution, which only happens on routes that opted in. Without it, nothing is hidden. It also forces the route to buffer, even with streaming: true.

The check runs once per matching paths entry, and its result applies to every hidden_blocks rule under it — never one backend call per element.

Not only about security

The mechanism only reads a status or a field. If /api/user returns {"is_birthday": true} once a year:

paths:
  - regex: '^/dashboard(/.*)?$'
    check_path: "/api/user"
    type_return: "json"
    expected_field: "is_birthday"
    expected_value: "false"
    hidden_blocks:
      - html_tag: '<div id="birthday-banner"></div>'
        fallback_html: '<div class="banner">Happy birthday!</div>'

Every ordinary day the check passes and the empty placeholder stays. On the birthday it fails and the fallback fills it. The same shape covers a billing-failure banner or a degraded-feature notice.

This is a patch layer, not a substitute for doing it properly in the application. Its real value shows with software you do not own — a vendor product, a self-hosted forge you do not want to fork: you change what visitors see without carrying a patch against upstream.

Fails closed

Every uncertain case resolves to “blocked”:

  • an IP that cannot be determined is treated as not on the list;
  • a check_path request that times out, fails to connect or returns something unexpected counts as not authenticated;
  • if neither target nor path yields anything usable, the visitor gets a bare 503.

In every branch the gate holds and the real content stays behind it.

A deployment window in practice

vhosts:
  - vhost: ["app.example.com"]
    redirect_protect:
      allow_ip: ["203.0.113.42"]
      target: "https://status.example.net"
      path: "/var/www/maintenance/index.html"
    allow_groups: ["staff"]
    routes:
      - prefix: "/"
        target: "http://127.0.0.1:8000"
        required_login: true

Add the block, save — routes.yml reloads. Deploy and test from your own address. Remove the block, save. No restart at either step.

An IP gate, fetched lists, a proxied fallback, a backend-verified session check and element-level hiding — one block, delegating the actual authority to whatever your application already knows how to answer, and holding closed whenever it cannot be sure.