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 Site assigned to the listener, with the intended hostnames, and a clear path match.

Steps ​

  1. To redirect a whole host, open Proxy -> Sites and create a draft site for old.example.com on public-https. Inside the site workspace, select Add first route and configure:

    FieldValue
    Priority10
    Path prefix/
    ActionRedirect
    ModeExternal origin
    Targethttps://new.example.com
    Status308
    Preserve path suffixOn
    Preserve queryOn

    Save the route, configure HTTPS certificate coverage for the site, and publish it. This sends:

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

    FieldValue
    Path prefix/old
    ModeSame host path
    Target/new
    Status302
  3. To serve a static maintenance response, open its site under Proxy -> Sites, select the route's Edit action, then select Add target and configure a static target:

    FieldValue
    Namemaintenance
    TypeStatic
    Status503
    BodyMaintenance in progress
    EnabledOn

    Expand Advanced target settings to select a reusable Generic body template or add response headers such as Content-Type and Retry-After. Create reusable bodies under Templates, then select one in the route drawer.

    p2pstream Edit Route drawer showing a static target with status, inline body, weight, priority group, and enabled controls
    A static target returns directly from p2pstream. The visible route drawer controls its status and inline body for deliberate local responses such as maintenance pages, probes, or temporary sink routes.
    p2pstream Edit Response Template drawer showing a generic-body template editor and sandboxed 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 in the same site:

    FieldValue
    Priority1
    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 unintended pathsNarrow the route's path match inside its site or disable the route after maintenance.
Template rejectedStatic targets can only use generic body templates.

Next Steps ​

Operations documentation for self-hosted p2pstream deployments.