-
Notifications
You must be signed in to change notification settings - Fork 3
/
default-nginx.conf
executable file
·36 lines (36 loc) · 1.4 KB
/
default-nginx.conf
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
server {
listen 8080;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri @prerender;
}
location @prerender {
set $prerender 0;
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp") {
set $prerender 1;
}
if ($args ~ "_escaped_fragment_") {
add_header X-debug-message "_escaped_fragment_ TRUE" always;
set $prerender 1;
}
if ($http_user_agent ~ "Prerender") {
add_header X-debug-message "_escaped_fragment_ FALSE" always;
set $prerender 0;
}
if ($uri ~* "\.(js|css|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|svg|eot)") {
set $prerender 0;
}
#resolve using Google's DNS server to force DNS resolution and prevent caching of IPs
resolver 8.8.8.8;
if ($prerender = 1) {
#setting prerender as a variable forces DNS resolution since nginx caches IPs and doesnt play well with load balancing
set $prerender "prerender.app.orbitsystems.gr";
rewrite .* /https://$host$request_uri? break;
proxy_pass https://$prerender;
}
if ($prerender = 0) {
rewrite .* /index.html break;
}
}
}