nginx
Render Engine With
NGINX
A few lines in your server block forward crawlers to Render Engine and leave everyone else on your site.
Steps
Set It Up
Step By Step
- 01
Add The Rule
Paste the snippet inside the server block for your public hostname.
- 02
Add Your API Key
Replace YOUR_RENDER_KEY with your key, and keep your own try_files lines where the snippet shows them.
- 03
Test And Reload
Run nginx -t, then reload nginx.
- 04
Check It Works
After a real crawler visits, the page appears in the Pages tab. To check now, use Recache on a page in the Pages tab and wait until its Rendered time updates, then request that page with a crawler user agent: you get the rendered copy from the cache. A crawler user agent sent from your own machine never starts a fresh render, so a page with no cached copy still shows your normal page.
Copy The Rule
Replace YOUR_RENDER_KEY with your API key, or copy it from the Setup page in the app with your key filled in. Any refusal, error or timeout falls through to your normal page. Keep nothing between your server and Render Engine that answers 200 on its own.
# Inside your server { } block. Replace the try_files lines with what your site already uses.
location / {
# Lets @lesuto_render hand any failure on to @lesuto_site (a second error_page).
recursive_error_pages on;
# $lesuto_fallback is set only in @lesuto_site; without this every page view logs a warning.
uninitialized_variable_warn off;
error_page 418 = @lesuto_render;
set $lesuto_render 0;
if ($http_user_agent ~* "(googlebot|bingbot|applebot|duckduckbot|yandexbot|baiduspider|oai-searchbot|chatgpt-user|gptbot|claude-searchbot|claude-user|claudebot|perplexity-user|perplexitybot|mistralai-user|duckassistbot|amazonbot|meta-externalagent|cohere-ai|youbot|facebookexternalhit|facebot|twitterbot|linkedinbot|pinterestbot|slackbot|discordbot|telegrambot|whatsapp)") { set $lesuto_render 1; }
if ($uri ~* "\.(js|css|xml|png|jpe?g|gif|pdf|ico|svg|webp|avif|woff2?|ttf|eot|map|txt|json|mp4|webm)$") { set $lesuto_render 0; }
if ($request_method != GET) { set $lesuto_render 0; }
# Your normal page standing in for a failed render: never back to Render Engine.
if ($lesuto_fallback = 1) { set $lesuto_render 0; }
if ($lesuto_render = 1) { return 418; }
try_files $uri $uri/ /index.html;
}
location @lesuto_render {
proxy_set_header X-Render-Key "YOUR_RENDER_KEY";
proxy_set_header X-Render-Url "$scheme://$host$request_uri";
# The address that connected. Behind a load balancer, set set_real_ip_from (that proxy only) and
# real_ip_header so this is the crawler's address.
proxy_set_header X-Render-Client-IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Host api.lesuto.com;
proxy_ssl_server_name on;
proxy_connect_timeout 5s;
proxy_send_timeout 18s;
proxy_read_timeout 18s;
# Any refusal, ended plan, error or timeout: your normal page.
proxy_intercept_errors on;
error_page 400 401 402 403 405 406 407 408 409 411 412 413 414 415 416 417 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 = @lesuto_site;
proxy_hide_header Cache-Control;
proxy_hide_header Vary;
# Render Engine's own sandbox policy is for its address, not your site's.
proxy_hide_header Content-Security-Policy;
add_header Cache-Control "private, max-age=0" always;
add_header CDN-Cache-Control "no-store" always;
add_header Vary "User-Agent" always;
rewrite ^ /api/v2/render-engine/render? break;
proxy_pass https://api.lesuto.com;
}
location @lesuto_site {
set $lesuto_fallback 1;
try_files $uri $uri/ /index.html;
}Full Guide
Every detail, edge case and fix on the Lesuto docs.
Other Ways To Set Up
Pick the stack that matches your site, or start from the checklist.
Rendered Pages
In About 15 Minutes
Add the rule, reload, and check one page.