← All tools

Self-hosted Prerender in Docker: prerender-alpine

Search engines and link previews often see an empty page when a site is rendered with JavaScript. Prerender fixes that by rendering the page in headless Chromium and serving bots the finished HTML. This container lets you run it yourself, configured only with environment variables.

This is a fork of tvanro/prerender-alpine. It currently ships Prerender 5.21.6, Chromium 142, Node 22 and Alpine 3.22.

What the fork adds

Quick start

There's no published image for this fork, so you build it from source:

git clone https://github.com/Silureth/prerender-alpine.git
cd prerender-alpine
cp .env.example .env        # set ALLOWED_DOMAINS etc.
docker compose up -d --build

Prerender now listens on 127.0.0.1:3000, so only a reverse proxy on the same host can reach it:

curl http://127.0.0.1:3000/health
curl 'http://127.0.0.1:3000/render?url=https://www.example.com/'

In Portainer, add a stack from the repository (https://github.com/Silureth/prerender-alpine, compose path docker-compose.yml) and set the environment variables you need.

Most used settings

VariableWhat it does
ALLOWED_DOMAINSComma-separated hostnames. All other domains get a 404.
BASIC_AUTH_USERNAME / _PASSWORDTurns on basic auth when both are set.
BROWSER_FORCE_RESTART_PERIODRestarts Chromium after this many ms, even under load. 3600000 is a good value for long-running instances.
BLOCK_RESOURCESSkips images, fonts and analytics for faster renders.
PAGE_LOAD_TIMEOUTMaximum render time in ms (default 20000).

The README lists every variable.

Caching

The recommended cache is nginx's proxy_cache in front of the container. It stores pages on disk, survives restarts, and renders a page only once when several bots ask for it at the same time. The README has a complete nginx config, including a secret header to refresh a single page.