nginx sends crawler requests (search engines, AI crawlers, link previews) to Prebaked and everything else to your site. Prebaked errors, outages and slow answers fall back to your site.
What it does
prebaked-maps.conf(generated from Prebaked's bot list) sets$prebaked_botfor known crawler user agents and$prebaked_staticfor static-file paths.prebaked.confcombines them: prerender onlyGET/HEAD, from a crawler, without anX-Prerenderheader (Prebaked's own page fetches), not a static file.- Crawler requests go to
https://service.prebaked.io/<scheme>://<host><path and query>withX-Prerender-Token.HEADis sent asGET. OnlyUser-Agent,Accept-Encoding,X-Prerender-Token,X-Prerender-Int-TypeandX-Forwarded-Forare sent (proxy_pass_request_headers off), never the visitor's cookies or credentials. ASet-Cookiefrom Prebaked is not passed to the crawler. proxy_intercept_errors+error_page: Prebaked 400, 401, 403, 5xx and 508, connection errors (502) and timeouts (504) serve your site. 200, redirects, 404 and 410 reach the crawler.
1. Copy the files
cp prebaked-maps.conf /etc/nginx/prebaked-maps.confprebaked.conf is a complete example (maps, upstreams, one server). Take the parts you need into your config:
- In the
httpcontext:include /etc/nginx/prebaked-maps.conf;, the threemapblocks andupstream prebaked_service. - In your
location /: theerror_page 418 = @prebaked;,recursive_error_pages on;andif ($prebaked_render) { return 418; }lines, before your existing directives. - In the same
server:location @prebakedandlocation @prebaked_fallback. Put your existing site directives into@prebaked_fallbacktoo.
Replace the placeholders:
| Placeholder | Value |
|---|---|
<your-prebaked-token> | Your token |
www.<your-domain> | Your site |
2. Static site (no app server)
If nginx serves your built files directly, use your root and try_files in both places instead of proxy_pass http://site_origin;:
location / {
error_page 418 = @prebaked;
recursive_error_pages on;
if ($prebaked_render) {
return 418;
}
root /var/www/<your-site>/dist;
try_files $uri /index.html;
}
location @prebaked_fallback {
root /var/www/<your-site>/dist;
try_files $uri /index.html;
}3. Reload and check
nginx -t && nginx -s reload
curl -A "Googlebot" https://www.<your-domain>/ # rendered HTML
curl https://www.<your-domain>/ # your normal pageThe first crawler request appears in the Prebaked dashboard request log.
Notes
- HTTPS to Prebaked with certificate verification (
proxy_ssl_verify on). The CA bundle path in the example is the Debian/Ubuntu/Alpine default; adjust it for your system. upstream prebaked_serviceresolvesservice.prebaked.iowhen nginx starts or reloads.proxy_read_timeout 5sis the time between two reads from Prebaked, not a limit on the whole response.- The page URL uses nginx's
$schemeand$host. If this nginx sits behind another TLS-terminating proxy,$schemeishttp: writehttpsinstead of$schemein theproxy_passline. - The visitor IP (
$remote_addr) is sent asX-Forwarded-Forso Prebaked can verify crawler IPs.