Skip to content

fix(edge): serve an Openship page for upstream-down 502/504 instead of OpenResty's stock one - #557

Merged
Hydralerne merged 3 commits into
oblien:feat/bugfix-batch-2026-09-16from
AbdullahM07:fix/edge-upstream-down-page
Sep 16, 2026
Merged

Hydralerne merged 3 commits into
oblien:feat/bugfix-batch-2026-09-16from
AbdullahM07:fix/edge-upstream-down-page

Conversation

@AbdullahM07

@AbdullahM07 AbdullahM07 commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

When a routed application stops answering, the host edge now serves an “Application unavailable” page for its own 502/504 responses. It preserves the HTTP status, leaves application-generated error responses unchanged, and covers proxy locations on otherwise static sites. Redirect-only and static-only routes keep their existing behavior.

Generation 3 upgrades saved generation-2 routes through the existing route replay mechanism. The page has no external links or reflected request values. This covers an available host with an unavailable application; errors generated by the separate Cloud edge when the host itself is unreachable are outside this repository.

Validation: 200 adapter/config tests and six real OpenResty cases pass, with API TypeScript passing. Three real HTTP cases and the existing-route upgrade regression fail against current main. The original contributor commit is retained, with the current architecture merged in and the test transport adapted to the current container-edge reload contract.

Fixes #556.

The edge defined no `error_page` for any 5xx, so an app that was restarting,
crashed, or still booting produced OpenResty's stock `502 Bad Gateway`. Behind
Openship Cloud's shared edge — which forwards to the box by IP and relays
whatever the box answers — that page is what a visitor to the operator's OWN
domain reads, branded for a third party. Closes oblien#556.

Adds the page as `edge-upstream-down.ts`, mirroring the unrouted-host page
(oblien#431): inline in the config for the same reason (it has to arrive on every
install path at once, and a missing `include` would be a hard `-t` failure that
freezes every later reload), the same five tokenizer invariants, and no links or
reflected values since it is served to strangers. Removing the third-party link
IS the fix — re-pointing it at the operator's own domain would only link to the
site that is currently down.

Wired at server scope in every vhost that proxies to an upstream: not host
redirects, and not static routes unless a compiled vercel.json gave them proxy
locations. Intercepts 502 and 504 only — `blockStatus` (403) and
`rateLimit.status` (429) are operator-overridable, so a 503 arm would brand a
deliberate block as an outage.

`VHOST_GENERATION` 1 -> 2, without which this reaches no existing box:
`registerRoute` is the sole writer, and `reapplyStoredRoutes` replays only
vhosts stamped below the current generation.

No `=` before the named location, so an intercepted 504 stays a 504 and one body
serves both codes. Verified against openresty/openresty:1.27.1.1-alpine rather
than assumed: with `=`, the named location's own return code replaces the
original and a timeout stops being reportable as one.

Verified: a new e2e boots real OpenResty with vhosts from the real
NginxProvider and checks a refused upstream (502 + our page), a read timeout
(504 + our page), an app's own 502 (its body passes through untouched, since
`proxy_intercept_errors` is off), a healthy app, a `.css` URI on a down app, and
a static vhost. Three of its six cases fail without this change, returning the
stock pages. Full adapters suite: 2879 pass.
@AbdullahM07
AbdullahM07 force-pushed the fix/edge-upstream-down-page branch from 4743cdd to 394c06b Compare August 16, 2026 11:51
@Hydralerne
Hydralerne changed the base branch from main to feat/bugfix-batch-2026-09-16 September 16, 2026 01:59
@Hydralerne
Hydralerne merged commit 90dd868 into oblien:feat/bugfix-batch-2026-09-16 Sep 16, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upstream-down hostnames return a raw OpenResty 502 instead of a friendly “Application unavailable” page

2 participants