-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathnginx.conf
71 lines (62 loc) · 1.49 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
map $http_user_agent $prerender_ua {
default 0;
"~Prerender" 0;
"~*baiduspider" 1;
"~*twitterbot" 1;
"~*baiduspider" 1;
"~*facebookexternalhit" 1;
"~*rogerbot" 1;
"~*linkedinbot" 1;
"~*embedly" 1;
"~*quora link preview" 1;
"~*showyoubot" 1;
"~*outbrain" 1;
"~*pinterest" 1;
"~*slackbot" 1;
"~*vkShare" 1;
"~*Slack-ImgProxy" 1;
"~*Slackbot-LinkExpanding" 1;
"~*Site Analyzer" 1;
"~*SiteAnalyzerBot" 1;
"~*Viber" 1;
"~*Whatsapp" 1;
"~*Discourse" 1;
"~*Telegram" 1;
"~*rocketchatbot" 1;
"~*W3C_Validator" 1;
}
# Generate $prerender bool value based on _escaped_fragement_ argument presence
# detection OR get the $prerender_ua bool value
map $args $prerender {
default $prerender_ua;
"~(^|&)_escaped_fragment_=" 1;
}
server {
listen 80;
resolver 8.8.8.8;
add_header Service-Worker-Allowed /;
location ~* ^/$ {
if ($prerender = 1) {
proxy_pass http://localhost:8080;
proxy_redirect off;
}
if ($http_cookie ~* "redirect_discovery") {
return 301 http://$server_name/discovery;
}
try_files $uri $uri/index.html /index.html =404;
}
location ~ ^/(u|artist|label|track)/(.*)$ {
if ($prerender = 1) {
proxy_pass http://localhost:8080;
proxy_redirect off;
}
try_files $uri $uri/index.html /$1/index.html /index.html =404;
}
location / {
if ($prerender = 1) {
proxy_pass http://localhost:8080;
proxy_redirect off;
}
try_files $uri $uri/index.html /index.html =404;
}
}