{"id":16137405,"url":"https://github.com/purarue/darker_errors","last_synced_at":"2025-09-06T17:42:14.135Z","repository":{"id":57567413,"uuid":"304568308","full_name":"purarue/darker_errors","owner":"purarue","description":"A dark-themed HTTP error page generator","archived":false,"fork":false,"pushed_at":"2024-10-24T22:55:38.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T22:51:15.836Z","etag":null,"topics":["html","html-templates","html5","nginx"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/purarue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-10-16T08:38:00.000Z","updated_at":"2024-10-24T22:55:41.000Z","dependencies_parsed_at":"2024-06-20T14:04:17.133Z","dependency_job_id":"95175f52-5b9b-4847-b70c-b5ac20e71aaf","html_url":"https://github.com/purarue/darker_errors","commit_stats":null,"previous_names":["purarue/darker_errors","seanbreckenridge/darker_errors"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fdarker_errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fdarker_errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fdarker_errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purarue%2Fdarker_errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purarue","download_url":"https://codeload.github.com/purarue/darker_errors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517919,"owners_count":20951719,"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":["html","html-templates","html5","nginx"],"created_at":"2024-10-09T23:26:52.571Z","updated_at":"2025-04-06T17:15:05.083Z","avatar_url":"https://github.com/purarue.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"A dark-themed HTTP error page generator.\n\n![preview](./.doc/preview.png)\n\nThis is purposefully minimal, it only generates static HTML. It's meant to be a fallback and replace the default blinding `nginx` error pages.\n\n![nginx](./.doc/nginx.jpeg)\n\nOn most of my servers, I'm typically running a reverse proxy with `nginx`, but I don't want to rely on `nginx`-specific syntax, or have to recompile `nginx` with additional modules, in case I want to use these error pages with something else.\n\nTo be clear, this is not `nginx` specific, its just why I created this. [Here's me using it](https://github.com/purarue/glue/tree/master/lib/glue_web/templates/error) in a completely different web framework; since they're just static HTML files its pretty trivial to add it to any sort of framework/server.\n\n### Install\n\n`go install github.com/purarue/darker_errors@latest`\n\n### Usage\n\nThis implements a small template language.\n\nIt replaces the strings:\n\n- `STATUS_CODE` (e.g. 404)\n- `STATUS_MSG` (e.g. Not Found)\n\nWith the corresponding HTTP values.\n\nTo override the default text for each page, you can use replacement directives:\n\n- `ERROR_TITLE` (Text in `\u003ctitle\u003e`; default: `STATUS_CODE - STATUS_MSG`\n- `ERROR_HEADING` (Large Heading; default: `\u003ch2\u003eSTATUS_CODE\u003c/h2\u003e`)\n- `ERROR_MSG` (Message; default: `\u003cp\u003eSTATUS_MSG\u003cp\u003e`)\n\nYou can also inject additional HTML by setting one of the following:\n\n- `ERROR_HEAD` (insert HTML into the `\u003chead\u003e` tag, can be used to add additional `\u003cstyle\u003e` or `\u003cmeta\u003e` tags)\n- `ERROR_BEFORE_HEADING` (before `ERROR_HEADING`)\n- `ERROR_AFTER_HEADING` (after `ERROR_HEADING`, before `ERROR_MSG`)\n- `ERROR_AFTER_MSG` (after `ERROR_MSG`)\n\nOptions:\n\n```\n  -nginx-conf\n        generate nginx configuration for mapping static html files\n  -output-dir string\n        output directory for *.html files (default \"error_html\")\n```\n\nAny additional positional arguments to `darker_errors` are interpreted as replacement directives.\n\n### Examples:\n\nInclude website name in `\u003ctitle\u003e`:\n\n```\ndarker_errors 'ERROR_TITLE:MyWebsite - STATUS_MSG'\n```\n\nIf you want to modify the text for just one page, you can specify that by using the HTTP status code\n\nInclude text to go back home on a 404:\n\n```\ndarker_errors '404:ERROR_AFTER_MSG:\u003cp\u003eClick \u003ca href=\"/\"\u003ehere\u003c/a\u003e to go back home.\u003cp\u003e`\n```\n\nTo left-align text and add a bit of margin: (Modifying the CSS in general would probably require you to take a look at how the elements are positioned in the HTML in [`src/template.go`](./src/template.go)).\n\n```\ndarker_errors 'ERROR_HEAD:\u003cstyle\u003e#flexbox { align-items: flex-start } #flexbox \u003e div { margin-left: 10%; }\u003c/style\u003e'\n```\n\nAdd a horizontal rule after the status code:\n\n```\ndarker_errors 'ERROR_AFTER_HEADING:\u003chr /\u003e' 'ERROR_HEAD:\u003cstyle\u003e hr { width: 80% }\u003c/style\u003e'\n```\n\nRefresh the page every 2 seconds if the user encountered a `502` error:\n\n```\ndarker_errors \\\n  '502:ERROR_HEAD:\u003cmeta http-equiv=\"refresh\" content=\"2\"\u003e' \\\n  '502:ERROR_MSG:\u003cp\u003eThis page is currently being updated...\u003cbr /\u003e This should be fixed in in a few seconds...\u003c/p\u003e'\n```\n\nIf you specify both `502:ERROR_MSG`, and `ERROR_MSG`, the `502` overwrites the generic replacement for the `502.html` page, while any other page uses the generic `ERROR_MSG` directive.\n\n## nginx setup\n\nMost of the time, I use nginx like:\n\n```\n# base elixir server handles everything\n  location / {\n    include /etc/nginx/pheonix_params;\n    proxy_pass http://localhost:8082;\n  }\n```\n\n.. i.e. every request which doesn't match some other location block gets sent to another 'base' webserver. That means its handles/renders its own HTTP errors, and nginx just forwards that back.\n\nHowever, whenever that upstream server is down, or restarting, the user just gets the blinding `502 Bad Gateway` page. To avoid that, I typically explicitly mark at least the 502 error code in my `nginx` configuration, with the generated page from here.\n\nTo do that, this assumes you've set a `root` in a `server` directive somewhere. That can be `/var/www/html/`, or some other folder.\n\nAs an example:\n\n```\nserver {\n  listen [::]:443 ssl ...\n  listen 443 ssl ...\n  ...\n  root /var/www/html;\n\n  # modified from https://stackoverflow.com/a/38414723/9348376\n\n  # base pheonix server which handles most of the requests\n  location @pheonix {\n    include /etc/nginx/pheonix_params;\n    proxy_pass http://localhost:8082;\n  }\n\n  # 502 route, in case upstream server is down\n  error_page 502 @offline;\n  location @offline {\n    # file should be at /var/www/html/502.html\n    try_files /502.html 502;\n  }\n\n  # if the path doesn't match some static file, forward to @pheonix server\n  location / {\n    try_files $uri @pheonix;\n  }\n}\n```\n\nIn the case above, since `root` is `/var/www/html`, put the generated `502.html` file at `/var/www/html/502.html`.\n\nIf you want to use this directly with `nginx`, you could put the `error_html` folder in `/var/www/html`, and then map each error code to the HTML page, like:\n\n```\nserver {\n  ...\n  error_page 401 /error_html/401.html;\n  error_page 404 /error_html/404.html;\n  error_page 502 /error_html/502.html;\n}\n```\n\nTo generate the configuration for that, you can run:\n\n```\ndarker_errors -nginx-conf\n```\n\n[`nginx` `error_page` documentation](https://nginx.org/en/docs/http/ngx_http_core_module.html#error_page)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Fdarker_errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurarue%2Fdarker_errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurarue%2Fdarker_errors/lists"}