-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnginx.conf
128 lines (102 loc) · 3.41 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
server {
listen 80;
server_name arasaac.org;
root /usr/share/nginx/html;
index index.html;
# location / {
# root /usr/share/nginx/html;
# try_files $uri /index.html;
# }
location / {
try_files $uri @prerender;
}
location @prerender {
# proxy_set_header X-Prerender-Token YOUR_TOKEN;
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_") {
set $prerender 1;
}
if ($http_user_agent ~ "Prerender") {
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 ipv6=off;
if ($prerender = 1) {
#setting prerender as a variable forces DNS resolution since nginx caches IPs and doesnt play well with load balancing
set $prerender "prerenderapp.arasaac.org";
# return 200 'location 1';
rewrite .* /$scheme://$host$request_uri? break;
proxy_pass https://$prerender;
}
if ($prerender = 0) {
# return 200 'location 2';
rewrite .* /index.html break;
}
}
# Do not cache sw.js, required for offline-first updates.
location /sw.js {
add_header Cache-Control "no-cache";
proxy_cache_bypass $http_pragma;
proxy_cache_revalidate on;
expires off;
access_log off;
}
location ~ ^/(api|zona_descargas|repositorio|catalogos.php|herramientas.php) {
rewrite ^/(.*)$ http://old.arasaac.org/$1 permanent;
}
location /ejemplos_uso.php {
rewrite ^/(.*)$ http://aulaabierta.arasaac.org/ejemplos-de-uso-caa permanent;
}
location /software.php {
rewrite ^/(.*)$ http://aulaabierta.arasaac.org/software permanent;
}
location /premios.php {
rewrite ^/(.*)$ /prizes permanent;
}
location /condiciones_uso.php {
rewrite ^/(.*)$ http://arasaac.org/terms-of-use permanent;
}
location /contacta.php {
rewrite ^/(.*)$ http://arasaac.org/contact-us permanent;
}
location /aac.php {
rewrite ^/(.*)$ http://arasaac.org/aac permanent;
}
location ~ ^/(pictogramas_color.php|pictogramas_byn.php) {
rewrite ^/(.*)$ http://arasaac.org/pictograms/search? permanent;
}
location ~ ^/(videos_lse.php|signos_lse_color.php) {
rewrite ^/(.*)$ http://arasaac.org/lse? permanent;
}
# location = /materiales.php {
# rewrite ^/(.*)$ /materials/search? permanent;
# }
location ~ /materiales.php {
if ($args ~* "(.*)(id_material=)(.*)") {
set $id $3;
set $args '';
return 301 /materials/es/$id?;
}
rewrite ^/(.*)$ /materials/search? permanent;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
server {
listen 80;
server_name www.arasaac.org arasaac.es www.arasaac.es;
# $scheme will get the http protocol
# and 301 is best practice for tablet, phone, desktop and seo
return 301 $scheme://arasaac.org$request_uri;
}