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
- Configuration through environment variables: basic auth, a domain allow-list and block-list, Chrome flags, a proxy and periodic browser restarts. No custom
server.jsneeded. - Safe plugin order: access control runs before the caches, so a cached page is never served to a client that would be rejected.
- A
/healthendpoint and a DockerHEALTHCHECK, so Docker and Portainer show the container as healthy or unhealthy. - Clean shutdown on
SIGTERM(docker stop, Kubernetes). - Reproducible builds with a committed lockfile and pinned Node and Alpine versions.
- A docker-compose file that works as it is, ready for Portainer.
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
| Variable | What it does |
|---|---|
ALLOWED_DOMAINS | Comma-separated hostnames. All other domains get a 404. |
BASIC_AUTH_USERNAME / _PASSWORD | Turns on basic auth when both are set. |
BROWSER_FORCE_RESTART_PERIOD | Restarts Chromium after this many ms, even under load. 3600000 is a good value for long-running instances. |
BLOCK_RESOURCES | Skips images, fonts and analytics for faster renders. |
PAGE_LOAD_TIMEOUT | Maximum 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.