# Prebaked TEST MODE "shadow" for nginx: requests pass through untouched, so your current setup # (your site and its existing prerender config) keeps answering every request. nginx sends a copy of each crawler request to Prebaked # in the background with X-Prebaked-Mode: shadow; Prebaked renders and caches the page, and its # answer is discarded. Example for the http context (e.g. conf.d/), next to prebaked-maps.conf. # Replace: , www., and the "YOUR CURRENT SETUP" parts with your # existing configuration. When you move on to "ai" or "all", use prebaked.conf instead. include /etc/nginx/prebaked-maps.conf; # $prebaked_bot, $prebaked_request_static (generated) map $request_method $prebaked_method { GET 1; HEAD 1; default 0; } # Loop guard: Prebaked's own page fetches carry X-Prerender and are never mirrored. map $http_x_prerender $prebaked_loop { "" 0; default 1; } # Mirror only: bot, GET/HEAD, no X-Prerender, not a static file. Uses $prebaked_request_static # because in the mirror location $uri is /_prebaked_shadow, not the page path. map "$prebaked_bot$prebaked_method$prebaked_loop$prebaked_request_static" $prebaked_shadow { "1100" 1; default 0; } upstream prebaked_service { server service.prebaked.io:443; } # YOUR CURRENT SETUP: an app server here; your current prerender config stays as it is. upstream site_origin { server 127.0.0.1:8080; } server { listen 80; server_name www.; location / { # Copy every request to /_prebaked_shadow; only crawler requests go on to Prebaked. mirror /_prebaked_shadow; mirror_request_body off; # YOUR CURRENT SETUP, unchanged proxy_pass http://site_origin; } location = /_prebaked_shadow { internal; if ($prebaked_shadow = 0) { return 204; # not a crawler page request: nothing is sent } # GET https://service.prebaked.io/://, unencoded. proxy_pass https://prebaked_service/$scheme://$host$request_uri; proxy_method GET; proxy_set_header Host service.prebaked.io; proxy_ssl_server_name on; proxy_ssl_name service.prebaked.io; proxy_ssl_verify on; proxy_ssl_verify_depth 4; # the default 1 rejects the Let's Encrypt chain proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; # Send only these headers and no body, never the visitor's cookies or credentials. proxy_pass_request_headers off; proxy_pass_request_body off; proxy_set_header Content-Length ""; proxy_set_header User-Agent $http_user_agent; proxy_set_header X-Prerender-Token ""; proxy_set_header X-Prerender-Int-Type nginx; proxy_set_header X-Prebaked-Mode shadow; proxy_set_header X-Forwarded-For $remote_addr; # The crawler already has its answer; these only limit how long nginx holds the copy open. proxy_connect_timeout 2s; proxy_send_timeout 5s; proxy_read_timeout 10s; } }