Skip to content

HTTP server

Paramtamtam edited this page Feb 24, 2022 · 9 revisions

For the HTTP server starts, you only need to specify the path to the configuration file (it does not need statically generated error pages). The server uses FastHTTP and stores all necessary data in memory - so it does not use the file system and very fast. Oh yes, the image with the app also contains a configured healthcheck, logs in JSON format, and metrics endpoint :) Just execute in your terminal:

$ docker run --rm \
    -p "8080:8080/tcp" \
    -e "TEMPLATE_NAME=random" \
    -e "SHOW_DETAILS=true" \
    tarampampam/error-pages

And open http://127.0.0.1:8080/404.html in your favorite browser. Error pages are accessible by the following URLs: http://127.0.0.1:8080/{page_code}.html. Another way is to pass the needed error page code (and HTTP response code) using the HTTP header X-Code when requesting an index page.

Additionally, the server respects the Content-Type HTTP header (and X-Format) value and responds with the corresponding format instead of the HTML-formatted response only. The xml and json content types (formats) are allowed at this moment, and its format can be fully customized using a configuration file!

For the integration with ingress-nginx (or debugging purposes) you can start the server with the flag --show-details (environment variable SHOW_DETAILS=true) - in this case, the error pages (json, xml responses too) will contain additional information that passed from the upstream reverse proxy!

Environment variable TEMPLATE_NAME should be used for the theme switching (supported templates are described in the project readme file).

💡 Cheat: you can use random (to use the randomized theme on server start) or i-said-random (to use the randomized template on each request) or random-daily/random-hourly (change themes in random order once a day/hourly)

If you want to proxy some HTTP headers from the requests to the responses you can use --proxy-headers flag or environment variable PROXY_HTTP_HEADERS (headers list should be comma-separated).

To see the help (supported flags, environment variable names) run the following command:

$ docker run --rm tarampampam/error-pages serve --help