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.
Features
How It Works
When custom error pages are enabled for a host and the response status is 400 or higher:- Aegis selects the template matching the status code (502, 503, 504) or falls back to the generic template
- If a custom template exists, Aegis renders it with variable substitution and CSS/JS injection
- If no custom template exists, Aegis renders the built-in default error page with the host’s branding settings
- 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
Template Selection
Aegis selects templates in the following priority order:- Status-specific template —
custom_502,custom_503, orcustom_504if it has content - Generic template —
custom_genericif it has content - Default template — built-in Aegis error page with host branding
html, css, or javascript fields are non-empty.
Security
- Logo URL sanitization — only
https://,http://, anddata:image/URIs are allowed; all other schemes are rejected - Contact URL sanitization — only
http://andhttps://URLs are allowed - Security headers — error responses include the same security headers configured for the host
- HSTS — error responses include
Strict-Transport-Securityif enabled for the host - Response cleanup —
Content-Encoding,Content-Range,ETag, andLast-Modifiedheaders are stripped from replaced responses

