{"id":13404118,"url":"https://github.com/HttpErrorPages/HttpErrorPages","last_synced_at":"2025-03-14T08:32:33.598Z","repository":{"id":25662050,"uuid":"29097688","full_name":"HttpErrorPages/HttpErrorPages","owner":"HttpErrorPages","description":":fast_forward: Simple HTTP Error Page Generator","archived":false,"fork":false,"pushed_at":"2024-08-11T18:02:38.000Z","size":575,"stargazers_count":934,"open_issues_count":5,"forks_count":200,"subscribers_count":23,"default_branch":"master","last_synced_at":"2024-08-11T18:13:47.075Z","etag":null,"topics":["apache-httpd","caddy","error-handling","error-messages","expressjs","html","http-errors","koajs","lighttpd","nginx","theme","webserver"],"latest_commit_sha":null,"homepage":"https://httperrorpages.github.io/HttpErrorPages/HTTP500.html","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HttpErrorPages.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-11T16:24:38.000Z","updated_at":"2024-08-11T18:13:55.188Z","dependencies_parsed_at":"2024-01-14T04:42:51.640Z","dependency_job_id":"76a58ccc-2882-4858-ac86-1fd28d55ba8f","html_url":"https://github.com/HttpErrorPages/HttpErrorPages","commit_stats":{"total_commits":71,"total_committers":10,"mean_commits":7.1,"dds":"0.43661971830985913","last_synced_commit":"67e35ccdda001aeed11f8978d85115dd0a6086c1"},"previous_names":["andidittrich/httperrorpages"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HttpErrorPages%2FHttpErrorPages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HttpErrorPages%2FHttpErrorPages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HttpErrorPages%2FHttpErrorPages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HttpErrorPages%2FHttpErrorPages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HttpErrorPages","download_url":"https://codeload.github.com/HttpErrorPages/HttpErrorPages/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221449580,"owners_count":16823621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-httpd","caddy","error-handling","error-messages","expressjs","html","http-errors","koajs","lighttpd","nginx","theme","webserver"],"created_at":"2024-07-30T19:01:39.313Z","updated_at":"2024-10-25T18:33:16.069Z","avatar_url":"https://github.com/HttpErrorPages.png","language":"JavaScript","readme":"[nginx](#nginx-integration) | \n[Apache HTTPD](#apache-httpd-integration) | \n[Lighttpd](#lighttpd-integration) | \n[express.js](#expressjs-integration) | \n[koa.js](#koajs-integration) | \n[Caddy](#caddy-integration) |\n[Customization](#customization)\n\n# Simple HttpErrorPages #\nSimple HTTP Error Page Generator. Create a bunch of custom error pages - suitable to use with Lighttpd, Nginx, expressjs, koajs ,Apache-Httpd or any other Webserver.\n\n![Screenshot](https://raw.githubusercontent.com/HttpErrorPages/HttpErrorPages/master/assets/screenshot1.png)\n\n## Features ##\n\n* Static pages (for webservers)\n* Multi-Language (i18n) support\n* Generator script to customize pages\n* Native [express.js](http://expressjs.com/) middleware\n* Native [koa.js](http://koajs.com/) middleware\n\n## Demo ##\n* [HTTP400](https://httperrorpages.github.io/HttpErrorPages/HTTP400.html)\n* [HTTP401](https://httperrorpages.github.io/HttpErrorPages/HTTP401.html)\n* [HTTP403](https://httperrorpages.github.io/HttpErrorPages/HTTP403.html)\n* [HTTP404](https://httperrorpages.github.io/HttpErrorPages/HTTP404.html)\n* [HTTP500](https://httperrorpages.github.io/HttpErrorPages/HTTP500.html)\n* [HTTP501](https://httperrorpages.github.io/HttpErrorPages/HTTP501.html)\n* [HTTP502](https://httperrorpages.github.io/HttpErrorPages/HTTP502.html)\n* [HTTP503](https://httperrorpages.github.io/HttpErrorPages/HTTP503.html)\n* [HTTP520](https://httperrorpages.github.io/HttpErrorPages/HTTP520.html)\n* [HTTP521](https://httperrorpages.github.io/HttpErrorPages/HTTP521.html)\n\n## Download ##\nJust clone/download the git repository **or** use the prebuild packages (only the generated html files are included)\n\n## Download Prebuild Packages (Pages only, en_US) ##\n\n* [Download Single Files](https://github.com/HttpErrorPages/HttpErrorPages/tree/master/dist)\n\n## NGINX Integration ##\n\n[NGINX](http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page) supports custom error-pages using multiple `error_page` directives.\n\nFile: [`default.conf`](https://www.nginx.com/resources/wiki/start/topics/examples/full/)\n\nExample - assumes HttpErrorPages are located into `/var/ErrorPages/`.\n\n```nginx\nserver {\n    listen      80;\n    server_name localhost;\n    root        /var/www;\n    index       index.html;\n    \n    location / {\n        try_files $uri $uri/ =404;\n        \n        # add one directive for each http status code\n        error_page 400 /ErrorPages/HTTP400.html;\n        error_page 401 /ErrorPages/HTTP401.html;\n        error_page 402 /ErrorPages/HTTP402.html;\n        error_page 403 /ErrorPages/HTTP403.html;\n        error_page 404 /ErrorPages/HTTP404.html;\n        error_page 500 /ErrorPages/HTTP500.html;\n        error_page 501 /ErrorPages/HTTP501.html;\n        error_page 502 /ErrorPages/HTTP502.html;\n        error_page 503 /ErrorPages/HTTP503.html;\n    }\n\n    # redirect the virtual ErrorPages path the real path\n    location /ErrorPages/ {\n        alias /var/ErrorPages/;\n        internal;\n    }\n```\n\n## Apache Httpd Integration ##\n[Apache Httpd 2.x](http://httpd.apache.org/) supports custom error-pages using multiple [ErrorDocument](http://httpd.apache.org/docs/2.4/mod/core.html#errordocument) directives.\n\nFile: `httpd.conf` or `.htaccess`\n\nExample - assumes HttpErrorPages are located into your **document root** `/var/www/...docroot../ErrorPages`.\n\n```ApacheConf\nErrorDocument 400 /ErrorPages/HTTP400.html\nErrorDocument 401 /ErrorPages/HTTP401.html\nErrorDocument 403 /ErrorPages/HTTP403.html\nErrorDocument 404 /ErrorPages/HTTP404.html\nErrorDocument 500 /ErrorPages/HTTP500.html\nErrorDocument 501 /ErrorPages/HTTP501.html\nErrorDocument 502 /ErrorPages/HTTP502.html\nErrorDocument 503 /ErrorPages/HTTP503.html\n```\n\n## Lighttpd Integration ##\n\n[Lighttpd](http://www.lighttpd.net/) supports custom error-pages using the [server.errorfile-prefix](http://redmine.lighttpd.net/projects/lighttpd/wiki/Server_errorfile-prefixDetails) directive.\n\nFile: `lighttpd.conf`\n\nExample - assumes HttpErrorPages are located into `/var/www/ErrorPages/`.\n\n```ApacheConf\nserver.errorfile-prefix = \"/var/www/ErrorPages/HTTP\"\n```\n\n## expressjs Integration ##\n\nHttpErrorPages are available as NPM-Package - just install `http-error-pages` via **npm/yarn**\n\n**Installation**\n\n```terminal\nyarn add http-error-pages\n```\n\n**Example**\n\nA ready-to-use example can be found in [examples/express.js](examples/express.js)\n\n```js\nconst _express = require('express');\nconst _webapp = _express();\nconst _httpErrorPages = require('http-error-pages');\n\nasync function bootstrap(){\n    // demo handler\n    _webapp.get('/', function(req, res){\n        res.type('.txt').send('HttpErrorPages Demo');\n    });\n\n    // throw an 403 error\n    _webapp.get('/my403error', function(req, res, next){\n        const myError = new Error();\n        myError.status = 403;\n        next(myError);\n    });\n\n    // throw an internal error\n    _webapp.get('/500', function(req, res){\n        throw new Error('Server Error');\n    });\n\n    // use http error pages handler (final statement!)\n    // because of the asynchronous file-loaders, wait until it has been executed\n    await _httpErrorPages.express(_webapp, {\n        lang: 'en_US',\n        payload: {\n            footer: 'Hello \u003cstrong\u003eWorld\u003c/strong\u003e',\n            myvar: 'hello world'\n        }\n    });\n\n    // start service\n    _webapp.listen(8888);\n}\n\n// invoke bootstrap operation\nbootstrap()\n    .then(function(){\n        console.log('Running Demo on Port 8888');\n    })\n    .catch(function(e){\n        console.error(e);\n    });\n```\n\n**Options**\n\nSyntax: `Promise _httpErrorPages.express(expressWebapp [, options:Object])`\n\n* `template` (type:string) - the path to a custom **EJS** template used to generate the pages. default [assets/template.ejs](assets/template.ejs)\n* `css` (type:string) - the path to a precompiled **CSS** file injected into the page. default [assets/layout.css](assets/layout.css)\n* `lang` (type:string) - language definition which should be used (available in the `i18n/` directory). default **en_US**\n* `payload` (type:object) - additional variables available within the template\n* `payload.footer` (type:string) - optional page footer content (html allowed). default **null**\n* `filter` (type:function) - filter callback to manipulate the variables before populated within the template\n* `onError` (type:function) - simple debug handler to print errors to the console (not to be used in production!)\n\n## koajs Integration ##\n\nHttpErrorPages are available as NPM-Package - just install `http-error-pages` via **npm/yarn**\n\n**Installation**\n\n```terminal\nyarn add http-error-pages\n```\n\n**Example**\n\nA ready-to-use example can be found in [examples/koa.js](examples/koa.js). \nKeep in mind that the following example has to be executed within an async context!\n\n```js\nconst _koa = require('koa');\nconst _webapp = new _koa();\nconst _httpErrorPages = require('http-error-pages');\n\n// use http error pages handler (INITIAL statement!)\n// because of the asynchronous file-loaders, wait until it has been executed - it returns an async handler\n_webapp.use(await _httpErrorPages.koa({\n    lang: 'en_US',\n    payload: {\n        footer: 'Hello \u003cstrong\u003eWorld\u003c/strong\u003e',\n        myvar: 'hello world'\n    }\n    \n}));\n\n// add other middleware handlers\n_webapp.use(async (ctx, next) =\u003e {\n    if (ctx.path == '/'){\n        ctx.type = 'text';\n        ctx.body = 'HttpErrorPages Demo';\n    }else{\n        return next();\n    }\n});\n\n// start service\n_webapp.listen(8888);\n```\n\n**Options**\n\nSyntax: `Promise _httpErrorPages.koa([options:Object])`\n\n* `template` (type:string) - the path to a custom **EJS** template used to generate the pages. default [assets/template.ejs](assets/template.ejs)\n* `css` (type:string) - the path to a precompiled **CSS** file injected into the page. default [assets/layout.css](assets/layout.css)\n* `lang` (type:string) - language definition which should be used (available in the `i18n/` directory). default **en_US**\n* `payload` (type:object) - additional variables available within the template\n* `payload.footer` (type:string) - optional page footer content (html allowed). default **null**\n* `filter` (type:function) - filter callback to manipulate the variables before populated within the template\n* `onError` (type:function) - simple debug handler to print errors to the console (not to be used in production!)\n\n## Caddy Integration ##\n\n[Caddy](https://caddyserver.com/docs/errors) supports custom error-pages using `errors` directive. \n\nFile: Caddyfile\n\nExample - assumes HttpErrorPages are located into `/var/www/error`.\n\n```Caddyfile\nwww.yoursite.com {\n    \n    // Other configurations\n\n    errors {\n        404 /var/www/error/HTTP404.html\n    }\n\n    // Other configurations\n\n}\n```\n\n## Customization ##\n\nFirst of all, [clone](https://github.com/HttpErrorPages/HttpErrorPages.git) \nor [download](https://github.com/HttpErrorPages/HttpErrorPages/archive/master.zip) the http-error-pages repository.\n\n### Install Dependencies ###\n\nYou have to install the node **dev** dependencies to build the pages:\n\n```bash\n# run the yarn command within the cloned repository\nyarn install\n\n# or if you more familiar with npm..\nnpm install\n```\n\nTo customize the pages, you can edit any of the [template files](assets/) and **finally run the generator-script**.\nAll generated html files are located into the `dist/` directory by default.\n\nIf you wan't to add custom pages/additional error-codes, just put a new entry into the `i18n/pages-en_US.json` file (its recommended to copy the file). \nThe generator-script will process each entry and generates an own page.\n\n### Files ###\n\n* [config.json](config.json) - basic configuration options\n* [assets/layout.scss](assets/layout.scss) - the SCSS based styles\n* [assets/template.ejs](assets/template.ejs) - the EJS based page template\n* [i18n/pages-\u003clang\u003e.json](i18n/) - the page definitions (multilanguage)\n* [dist/*.html](dist/) - generator output directory\n\n### Change page styles ###\n\nTo modify the page styles, just edit the SCSS based layout [assets/layout.scss](assets/layout.scss) and finally run **gulp** to generate the css code.\nThe new layout file is stored in [assets/layout.css](assets/layout.css) - run the page generator to create the pages.\n\n**Example**\n\n```bash\n# start gulp sccs via npm\n$ npm run gulp\n\n\u003e http-error-pages@0.6.0 gulp HttpErrorPages\n\u003e gulp\n\n[08:40:33] Using gulpfile HttpErrorPages/gulpfile.js\n[08:40:33] Starting 'sass'...\n[08:40:34] Finished 'sass' after 108 ms\n[08:40:34] Starting 'default'...\n[08:40:34] Finished 'default' after 40 μs\n\n# generate http-error-pages using modified stylesheet\n$ npm run static\n\n\u003e http-error-pages@0.6.0 static HttpErrorPages\n\u003e node bin/generator.js static\n\nPaths\n |- Config: HttpErrorPages/config.json\n |- Template: HttpErrorPages/assets/template.ejs\n |- Styles: HttpErrorPages/assets/layout.css\n |- Pages: HttpErrorPages/i18n/pages-en_US.json\n\nGenerating static pages\n |- Page \u003cHTTP404.html\u003e\n |- Page \u003cHTTP403.html\u003e\n |- Page \u003cHTTP400.html\u003e\n |- Page \u003cHTTP500.html\u003e\n |- Page \u003cHTTP501.html\u003e\n |- Page \u003cHTTP502.html\u003e\n |- Page \u003cHTTP520.html\u003e\n |- Page \u003cHTTP503.html\u003e\n |- Page \u003cHTTP521.html\u003e\n |- Page \u003cHTTP533.html\u003e\n |- Page \u003cHTTP401.html\u003e\nStatic files generated\n```\n\n### Multi language (i18n) ###\n\nTo use a different language just provide a custom [page definition](i18n/) - in case the file is located in `i18n` you can use the `--lang option`\n\n**Example**\n```terminal\n$ npm run static -- --lang pt_BR\n\n\u003e http-error-pages@0.6.0 static HttpErrorPages\n\u003e node bin/generator.js static \"--lang\" \"pt_BR\"\n\nPaths\n |- Config: HttpErrorPages/config.json\n |- Template: HttpErrorPages/assets/template.ejs\n |- Styles: HttpErrorPages/assets/layout.css\n |- Pages: HttpErrorPages/i18n/pages-pt_BR.json\n\nGenerating static pages\n |- Page \u003cHTTP404.html\u003e\n |- Page \u003cHTTP400.html\u003e\n |- Page \u003cHTTP401.html\u003e\n |- Page \u003cHTTP403.html\u003e\n |- Page \u003cHTTP500.html\u003e\n |- Page \u003cHTTP501.html\u003e\n |- Page \u003cHTTP502.html\u003e\n |- Page \u003cHTTP520.html\u003e\n |- Page \u003cHTTP503.html\u003e\n |- Page \u003cHTTP521.html\u003e\n |- Page \u003cHTTP533.html\u003e\nStatic files generated\n\n```\n\n### Add custom pages ###\n\nCreate custom error codes/pages used by e.g. CloudFlare\n\n**Example**\n```js\n// webserver origin error\n\"520\": {\n    \"title\": \"Origin Error - Unknown Host\",\n    \"message\": \"The requested hostname is not routed. Use only hostnames to access resources.\"\n},\n\n// webserver down error\n\"521\": {\n    \"title\": \"Webservice currently unavailable\",\n    \"message\": \"We've got some trouble with our backend upstream cluster.\\nOur service team has been dispatched to bring it back online.\"\n},\n```\n\n### Change footer message ###\n\nThe footer message can easily be changed/removed by editing [config.json](config.json).\n\n**Example - customm footer**\n\n```js\n{\n    //  Output Filename Scheme - eg. HTTP500.html\n    \"scheme\": \"HTTP%code%.html\",\n\n    // Footer content (HTML Allowed)\n    \"footer\": \"Contact \u003ca href=\\\"mailto:info@example.org\\\"\u003einfo@example.org\u003c/a\u003e\"\n}\n```\n\n**Example - no footer**\n\n```js\n{\n    //  Output Filename Scheme - eg. HTTP500.html\n    \"scheme\": \"HTTP%code%.html\"\n}\n```\n\n### Placeholders/Variables ###\n\nThe following set of variables is exposed to the ejs template (404 page example):\n\n```js\n{\n  title: 'Resource not found',\n  message: 'The requested resource could not be found but may be available again in the future.',\n  code: '404',\n  language: 'en',\n  scheme: 'HTTP%code%.html',\n  pagetitle: \"We've got some trouble | %code% - %title%\",\n  footer: 'Tech Contact \u003ca href=\"mailto:info@example.org\"\u003einfo@example.org\u003c/a\u003e',\n  myvar: 'Hello World'\n}\n```\n\nTo generate dynamic titles/content based on the current variable set, each variable is exposed as `placeholder` (surrounded by `%`). \n\nYou can also define custom variable within the page definitions, everything is merged togehter.\n\n### Modify the HTML template ###\n\nThe HTML template is based on [ejs](https://github.com/mde/ejs) and located in [assets/template.ejs](assets/template.ejs) - you can apply any kind of changes.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"\u003c%= vars.language %\u003e\"\u003e\n\u003chead\u003e\n    \u003c!-- Simple HttpErrorPages | MIT License | https://github.com/HttpErrorPages --\u003e\n    \u003cmeta charset=\"utf-8\" /\u003e\u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" /\u003e\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /\u003e\n    \u003ctitle\u003e\u003c%= vars.pagetitle %\u003e\u003c/title\u003e\n    \u003cstyle type=\"text/css\"\u003e\u003c%- vars.inlinecss %\u003e\u003c/style\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n    \u003cdiv class=\"cover\"\u003e\u003ch1\u003e\u003c%= vars.title %\u003e \u003csmall\u003e\u003c%= vars.code %\u003e\u003c/small\u003e\u003c/h1\u003e\u003cp class=\"lead\"\u003e\u003c%= vars.message %\u003e\u003c/p\u003e\u003c/div\u003e\n    \u003c% if (vars.footer){ %\u003e\u003cfooter\u003e\u003cp\u003e\u003c%- vars.footer %\u003e\u003c/p\u003e\u003c/footer\u003e\u003c% } %\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Command line options ###\n\nThe [http-error-pages generator](bin/generator.js) allows you to use custom template/config files directly. **This is the recommended method to create full-customized pages.**\n\n```terminal\n$ npm run static -- --help\n\n\u003e http-error-pages@0.6.0 static HttpErrorPages\n\u003e node bin/generator.js static \"--help\"\n\n  Usage: static [options] [config]\n\n  run http-error-pages generator\n\n  Options:\n\n    -t, --template \u003cpath\u003e  path to your custom EJS template file\n    -s, --styles \u003cpath\u003e    path to your custom stylesheet (precompiled as CSS!)\n    -p, --pages \u003cpath\u003e     path to your custom page definition\n    -l, --lang \u003clang\u003e      the language of the default page definition\n    -o, --out \u003cpath\u003e       output directory\n    -h, --help             output usage information\n```\n\n**Example - use custom files**\n\nWe assume you've created a folder named `example_org` which contains all relevant template files\n\n```bash\n# via npm run-script (cross platform)\n$ npm run static -- -t example_org/template.ejs -s example_org/styles.css -p example_org/pages.json -o example_org/output\n\n# .. or directly (linux only)\n$ http-error-pages -t example_org/template.ejs -s example_org/styles.css -p example_org/pages.json -o example_org/output\n```\n\n## License ##\nHttpErrorsPages is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT) - your're welcome to contribute\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHttpErrorPages%2FHttpErrorPages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FHttpErrorPages%2FHttpErrorPages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FHttpErrorPages%2FHttpErrorPages/lists"}