This repository was archived by the owner on Feb 20, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx-default.conf
More file actions
48 lines (43 loc) · 2.39 KB
/
nginx-default.conf
File metadata and controls
48 lines (43 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
map $http_user_agent $use_prerender {
default 0;
"~*(360Spider|AdsBot-Google|AhrefsBot|AhrefsSiteAudit|Amazonbot|Applebot|Arquivo-web-crawler|Baiduspider|BingPreview|Bingbot|Bitrix link preview|CCBot|Chrome-Lighthouse|Crawler|Discordbot|DotBot|DuckDuckBot|Facebot|Feedly|Google-Extended|Google-InspectionTool|GoogleOther|Googlebot|GrapeshotCrawler|HubSpot Crawler|Iframely|LinkedInBot|MJ12bot|Mastodon|MojeekBot|Neevabot|PetalBot|Qwantify|SISTRIX Crawler|Screaming Frog SEO Spider|SemrushBot|SeznamBot|SkypeUriPreview|Slack-ImgProxy|Slackbot|Sogou web spider|Storebot-Google|TelegramBot|TinEye-bot|Twitterbot|WhatsApp|XoviBot|Yahoo! Slurp|Yandex|Yeti|YisouSpider|ZoominfoBot|bitlybot|coccocbot|developers\.google\.com/\+/web/snippet|embedly|facebookexternalhit|ia_archiver|outbrain|pinterestbot|proximic|quora link preview|redditbot|rogerbot|search\.ch|serpstatbot|vkShare|yacybot)" 1;
}
map $request_uri $skip_prerender {
default 0;
"~*\.(css|js|eot|eot2|woff|woff2|otf|ttf|otc|sfnt)$" 1;
"~*\.(gif|ico|jpeg|jpg|png|svg|tiff|bmp|webp|avif|jxl|heic|heif)$" 1;
"~*\.(mp3|mp4|webm|ogg|wav|flac|m4a|m4v|avi|mov|mkv|mpg|mpeg|wmv|swf)$" 1;
"~*\.(txt|json|xml|csv|pdf|doc|docx|xls|xlsx|ppt|pptx|rtf|odt|ods|odp)$" 1;
"~*\.(zip|rar|7z|tar|gz|bz2|tgz)$" 1;
"~*\.(less|sass|scss|styl|coffee|ts)$" 1;
"~*\.(wasm|manifest|appcache)$" 1;
"~*/(robots|ads)\.txt$" 1;
}
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
error_page 500 502 503 504 /50x.html;
location / {
resolver 8.8.8.8;
set $prerenderServer "prerender.example.net"; # Replace with your prerender instance
set $prerender 0;
if ($use_prerender = 1) {
set $prerender 1;
}
if ($skip_prerender = 1) {
set $prerender 0;
}
if ($prerender = 1) {
# The `https` on the `rewrite` line forces HTTPS instead of using $scheme (so prerender will always access)
# your original website using HTTPS.
# The `https` on the `proxy_pass` line forces Nginx to access your prerender server using HTTPS.
rewrite .* /https://$host$request_uri;
proxy_pass https://$prerenderServer;
break;
}
# If prerender is not activated, try to serve static files instead
try_files $uri $uri/index.html /index.html;
}
}