Skip to content

Redirects and Static Responses

Return redirects or fixed local responses without forwarding the request to an upstream service.

Use This When

Use redirects for host/path migrations. Use static responses for maintenance pages, health probes, or deliberate sink routes.

Prerequisites

  • A listener that receives the public request.
  • A clear host/path match so the redirect or static route does not catch unrelated traffic.

Steps

  1. To redirect a whole host, open Proxy -> Routes and create:

    FieldValue
    Listenerpublic-https
    Priority10
    Host patternold.example.com
    Path prefix/
    ActionRedirect
    Redirect modeExternal origin keep path
    Redirect targethttps://new.example.com
    Status308
    Preserve queryOn

    This sends:

    text
    https://old.example.com/docs?a=1 -> https://new.example.com/docs?a=1
    p2pstream route editor showing an external redirect route with status and query preservation
    The redirect route editor keeps redirect mode, target, status code, path suffix preservation, and query handling with the route match that triggers it.
  2. To redirect a path on the same host, use same-host path mode:

    FieldValue
    Host patternapp.example.com
    Path prefix/old
    Redirect modeSame host path
    Redirect target/new
    Status302
  3. To serve a static maintenance response, open the matching route in Proxy and add a static target:

    FieldValue
    Namemaintenance
    TypeStatic
    Status code503
    Body sourceInline
    Response bodyMaintenance in progress
    HeaderRetry-After: 300

    For reusable HTML maintenance pages, first open Templates, create a Generic body template, then set the static target body source to Template and select it. Keep response headers, especially Content-Type, on the static target.

    p2pstream route target editor showing a static response backed by a response template
    The static response target returns directly from p2pstream. Use it for deliberate local responses such as maintenance pages, probes, or temporary sink routes.
    p2pstream generic response template editor showing template name, kind, content type, body, and preview
    Generic response templates centralize reusable bodies for static targets, rate-limit responses, and WAF block responses while each caller keeps control of status and headers.
  4. Give that route a lower priority number than the normal app route:

    FieldValue
    Priority1
    Host patternapp.example.com
    Path prefix/
    Targetmaintenance

Verification

Run:

bash
curl -I https://old.example.com/docs?a=1
curl -i https://app.example.com/

Redirect routes should return 301, 302, 307, or 308. Static routes should return the configured status, body, and headers.

Troubleshooting

SymptomCheck
Redirect target rejectedSame-host targets must be root-relative paths; external-origin targets must be HTTP/HTTPS origins.
Wrong route winsLower priority numbers run first.
Static route affects all trafficNarrow host/path match or disable the route after maintenance.
Template option rejectedStatic targets can only use generic body templates.

Next Steps

Operations documentation for self-hosted p2pstream deployments.