Skip to main content

Custom Error Pages

Aegis renders branded error pages when the upstream returns an error or is unreachable. Each proxy host can define status-specific HTML templates, branding, and contact information — or use the built-in default template.
Image

Features


How It Works

When custom error pages are enabled for a host and the response status is 400 or higher:
  1. Aegis selects the template matching the status code (502, 503, 504) or falls back to the generic template
  2. If a custom template exists, Aegis renders it with variable substitution and CSS/JS injection
  3. If no custom template exists, Aegis renders the built-in default error page with the host’s branding settings
  4. The original upstream response body is replaced with the rendered error page

Configuration

Error page configuration is stored as part of the proxy host settings: Each template object contains three fields:

Template Variables

Custom templates support variable substitution in two formats:

Template Rendering

Aegis handles two template formats:

Full HTML Documents

If the HTML contains <html, <head, or <body tags, Aegis treats it as a full document:
  • CSS is injected as a <style> block before </head>
  • JavaScript is injected as a <script> block before </body>

HTML Fragments

If the HTML is a fragment (no document structure), Aegis wraps it in a proper document with <meta charset> and viewport tags, injecting CSS and JS in the appropriate locations.

Default Template

When no custom template matches the status code, Aegis renders a built-in error page with the following design:
  • Dark theme with radial gradient background
  • Glassmorphic panel design (backdrop blur, semi-transparent background)
  • Large status code display with configurable accent color
  • Status text and human-readable error description
  • Metadata pills for host, incident ID, and timestamp
  • Contact email and issue-reporting link
  • Responsive layout (max width 640px)
  • IBM Plex Sans / Segoe UI font stack
The default template respects all branding settings — brand name, logo, accent color, and contact information are applied automatically.

Template Selection

Aegis selects templates in the following priority order:
  1. Status-specific templatecustom_502, custom_503, or custom_504 if it has content
  2. Generic templatecustom_generic if it has content
  3. Default template — built-in Aegis error page with host branding
A template is considered to have content if any of its html, css, or javascript fields are non-empty.

Security

  • Logo URL sanitization — only https://, http://, and data:image/ URIs are allowed; all other schemes are rejected
  • Contact URL sanitization — only http:// and https:// URLs are allowed
  • Security headers — error responses include the same security headers configured for the host
  • HSTS — error responses include Strict-Transport-Security if enabled for the host
  • Response cleanupContent-Encoding, Content-Range, ETag, and Last-Modified headers are stripped from replaced responses

Error Status Mapping

When the upstream is unreachable, Aegis maps the proxy error to the appropriate status: