⚠️ Simple HTTP Error Page Generator
HTML CSS PHP
Latest commit 0331dac Aug 3, 2016 @AndiDittrich committed on GitHub Fixed #1
Added a working nginx example how to set up the error pages

README.md

Simple HttpErrorPages

Simple HTTP Error Page Generator. Create a bunch of custom error pages - suitable to use with Lighttpd, Nginx, Apache or Tomcat.

Screenshot

Demo

Integration

Lighttpd

Lighttpd supports custom error-pages using the server.errorfile-prefix directive.

File: lighttpd.conf

Example - assumes HttpErrorPages are located into /var/www/ErrorPages/.

server.errorfile-prefix = "/var/www/ErrorPages/HTTP"

Apache Httpd

Apache Httpd 2.x supports custom error-pages using multiple ErrorDocument directives.

File: httpd.conf or .htaccess

Example - assumes HttpErrorPages are located into your document root /var/www/...docroot../ErrorPages.

ErrorDocument 400 /ErrorPages/HTTP400.html
ErrorDocument 401 /ErrorPages/HTTP401.html
ErrorDocument 403 /ErrorPages/HTTP403.html
ErrorDocument 404 /ErrorPages/HTTP404.html
ErrorDocument 500 /ErrorPages/HTTP500.html
ErrorDocument 501 /ErrorPages/HTTP501.html
ErrorDocument 502 /ErrorPages/HTTP502.html
ErrorDocument 503 /ErrorPages/HTTP503.html

NGINX

NGINX supports custom error-pages using multiple error_page directives.

File: default.conf

Example - assumes HttpErrorPages are located into /var/www/ErrorPages/.

# add one directive for each http status code
error_page 400 /ErrorPages/HTTP400.html;
error_page 401 /ErrorPages/HTTP401.html;
error_page 402 /ErrorPages/HTTP402.html;
error_page 403 /ErrorPages/HTTP403.html;
error_page 404 /ErrorPages/HTTP404.html;
error_page 500 /ErrorPages/HTTP500.html;
error_page 501 /ErrorPages/HTTP501.html;
error_page 502 /ErrorPages/HTTP502.html;
error_page 503 /ErrorPages/HTTP503.html;

# redirect the virtual ErrorPages path the real path
location /ErrorPages/ {
       alias /var/www/ErrorPages/;
       internal;
}

Customization

To customize the pages, you can edit the template.phtml file and add your own styles. Finally run the generator-script. If you wan't to add custom pages/additional error-codes, just put a new entry into the pages.php file. The generator-script will process each entry and generates an own page.

Custom Page Example (pages.php)

Error-Codes used by CloudFlare

// webserver origin error
'520' => array(
    'title' => 'Origin Error - Unknown Host',
    'message' => 'The requested hostname is not routed. Use only hostnames to access resources.'
),

// webserver down error
'521' => array (
        'title' => 'Webservice currently unavailable',
        'message' => "We've got some trouble with our backend upstream cluster.\nOur service team has been dispatched to bring it back online."
)   

Build/Generator

Used Naming-Scheme: HTTPCODE.html (customizable by editing the generator script) To generate the static html pages, run the generator.php script:

php generator.php

All generated html files are located into the Build/ directory.

License

HttpErrorsPages is OpenSource and licensed under the Terms of The MIT License (X11) - your're welcome to contribute