Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: modules/adblockplusorg/files/adblockplus.org

Issue 9048063: infrastructure: Redirects for the new website (Closed)
Patch Set: Created Dec. 19, 2012, 8 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 server { 1 server {
2 root /var/www/adblockplus.org/httpdocs; 2 root /var/www/adblockplus.org/httpdocs;
3 3
4 location / { 4 location / {
5 index index.php index index.html; 5 index index.php index index.html;
6 6
7 if ($arg_a = "view") { 7 if ($arg_a = "view") {
8 rewrite ^(.*) $1? permanent; 8 rewrite ^(.*) $1? permanent;
9 } 9 }
10 10
11 set $preferredLang en; 11 set $preferredLang en;
12 if ($http_accept_language ~ ^(\w\w)\b) { 12 if ($http_accept_language ~ ^(\w\w)\b) {
13 set $preferredLang $1; 13 set $preferredLang $1;
14 } 14 }
15 if (!-f $document_root/static/$preferredLang/index) { 15 if (!-f $document_root/static/$preferredLang/index) {
16 set $preferredLang en; 16 set $preferredLang en;
17 } 17 }
18 18
19 if ($arg_a ~ ^(view|show)?$) { 19 set $browser "firefox";
20 rewrite ^/(index\.html)?$ /$preferredLang/? redirect; 20 if ($http_user_agent ~ \bChrome/\d+) {
21 rewrite ^/(\w\w(_\w\w)?)$ /$1/ redirect; 21 set $browser "chrome";
22 }
23 if ($http_user_agent ~ \bPresto/\d+) {
24 set $browser "opera";
25 }
26 if ($http_user_agent ~ \bAndroid\s.*\bAppleWebKit/\d+) {
27 set $browser "android";
22 } 28 }
23 29
24 rewrite ^/(\w\w)/installation$ /$1/ permanent; 30 if ($arg_a ~ ^(view|show)?$) {
31 rewrite ^/(index\.html)?$ /$preferredLang/$browser redirect;
32 rewrite ^/(\w\w(_\w\w)?)$ /$1/$browser redirect;
33 }
34
35 rewrite ^/(\w\w(_\w\w)?)/installation$ /$1/ permanent;
25 rewrite ^/anwiki/(.*) /$1 permanent; 36 rewrite ^/anwiki/(.*) /$1 permanent;
26 37
27 if (-f $request_filename) { 38 if (-f $request_filename) {
28 break; 39 break;
29 } 40 }
30 if (-d $request_filename) { 41 if (-d $request_filename) {
31 break; 42 break;
32 } 43 }
33 44
34 if ($http_user_agent ~ \bChrome/\d+) { 45 set $static_uri $uri;
35 rewrite ^/(\w\w(_\w\w)?)/?$ /$1/chrome; 46 if ($uri ~ ^/(\w\w(_\w\w)?)/(firefox|chrome|opera|android)) {
47 set $static_uri "/$1/";
48 set $browser $3;
36 } 49 }
37 if ($http_user_agent ~ \bPresto/\d+) {
38 rewrite ^/(\w\w(_\w\w)?)/?$ /$1/opera;
39 }
40 if ($http_user_agent !~ \bChrome/\d+) {
41 rewrite ^/(\w\w(_\w\w)?)/?$ /$1/firefox;
42 }
43
44 set $static ""; 50 set $static "";
45 if (-f "$document_root/static$uri") { 51 if (-f "$document_root/static$static_uri") {
46 set $static "ok"; 52 set $static "ok";
47 } 53 }
48 if (-d "$document_root/static$uri") { 54 if (-d "$document_root/static$static_uri") {
49 set $static "ok"; 55 set $static "ok";
50 } 56 }
51 set $static "$static!$arg_a!$cookie_anwiki_anwsesscode"; 57 set $static "$static!$arg_a!$cookie_anwiki_anwsesscode";
52 if ($static ~ ^ok!(view|show)?!$) { 58 if ($static ~ ^ok!(view|show)?!$) {
53 rewrite (.*) /static$1 last; 59 rewrite ^ /static$static_uri?browser=$browser last;
54 } 60 }
55 61
62 rewrite ^/(\w\w(_\w\w)?)/(firefox|chrome|opera|android) /index.php?p=$1&brow ser=$3 last;
56 rewrite ^/(.*) /index.php?p=$1 last; 63 rewrite ^/(.*) /index.php?p=$1 last;
57 } 64 }
58 65
59 location /static/ { 66 location /static/ {
60 index index; 67 index index;
61 internal; 68 internal;
62 types { 69 types {
63 image/png png; 70 image/png png;
64 text/xml xml; 71 text/xml xml;
65 text/css css; 72 text/css css;
66 } 73 }
67 default_type text/html; 74 default_type text/html;
68 charset utf-8; 75 charset utf-8;
69 76
70 set $browserClass ' nongecko'; 77 if ($arg_browser) {
71 if ($http_user_agent ~ \bGecko/\d+) { 78 set $browser_class ' class="$arg_browser"';
72 set $browserClass ' gecko';
73 } 79 }
74 if ($http_user_agent ~ \bK-Meleon\b) { 80 sub_filter ' id="content"' ' id="content"$browser_class';
75 set $browserClass ' kmeleon';
76 }
77 if ($http_user_agent ~ \bChrome/\d+) {
78 set $browserClass ' chrome';
79 }
80 if ($http_user_agent ~ \bPresto/\d+) {
81 set $browserClass ' opera';
82 }
83 sub_filter ' id="content" class="multicolumn"' ' id="content" class="multi column$browserClass"';
84 } 81 }
85 82
86 83
87 location ~ \.php$ { 84 location ~ \.php$ {
88 client_max_body_size 8m; 85 client_max_body_size 8m;
89 86
90 set $browserClass ' nongecko'; 87 if ($arg_browser) {
91 if ($http_user_agent ~ \bGecko/\d+) { 88 set $browser_class ' class="$arg_browser"';
92 set $browserClass ' gecko';
93 } 89 }
94 if ($http_user_agent ~ \bK-Meleon\b) { 90 sub_filter ' id="content"' ' id="content"$browser_class';
95 set $browserClass ' kmeleon';
96 }
97 if ($http_user_agent ~ \bChrome/\d+) {
98 set $browserClass ' chrome';
99 }
100 if ($http_user_agent ~ \bPresto/\d+) {
101 set $browserClass ' opera';
102 }
103 sub_filter ' id="content" class="multicolumn"' ' id="content" class="multico lumn$browserClass"';
104 91
105 fastcgi_pass unix:/tmp/php-fastcgi.sock; 92 fastcgi_pass unix:/tmp/php-fastcgi.sock;
106 fastcgi_index index.php; 93 fastcgi_index index.php;
107 94
108 fastcgi_param SCRIPT_FILENAME /var/www/adblockplus.org/phproot$fastcgi_scrip t_name; 95 fastcgi_param SCRIPT_FILENAME /var/www/adblockplus.org/phproot$fastcgi_scrip t_name;
109 96
110 fastcgi_param QUERY_STRING $query_string; 97 fastcgi_param QUERY_STRING $query_string;
111 fastcgi_param REQUEST_METHOD $request_method; 98 fastcgi_param REQUEST_METHOD $request_method;
112 fastcgi_param CONTENT_TYPE $content_type; 99 fastcgi_param CONTENT_TYPE $content_type;
113 fastcgi_param CONTENT_LENGTH $content_length; 100 fastcgi_param CONTENT_LENGTH $content_length;
114 101
115 fastcgi_param SCRIPT_NAME $fastcgi_script_name; 102 fastcgi_param SCRIPT_NAME $fastcgi_script_name;
116 fastcgi_param REQUEST_URI $request_uri; 103 fastcgi_param REQUEST_URI $request_uri;
117 fastcgi_param DOCUMENT_URI $document_uri; 104 fastcgi_param DOCUMENT_URI $document_uri;
118 fastcgi_param DOCUMENT_ROOT $document_root; 105 fastcgi_param DOCUMENT_ROOT $document_root;
119 fastcgi_param SERVER_PROTOCOL $server_protocol; 106 fastcgi_param SERVER_PROTOCOL $server_protocol;
120 107
121 fastcgi_param GATEWAY_INTERFACE CGI/1.1; 108 fastcgi_param GATEWAY_INTERFACE CGI/1.1;
122 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 109 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
123 110
124 fastcgi_param REMOTE_ADDR $remote_addr; 111 fastcgi_param REMOTE_ADDR $remote_addr;
125 fastcgi_param REMOTE_PORT $remote_port; 112 fastcgi_param REMOTE_PORT $remote_port;
126 fastcgi_param SERVER_ADDR $server_addr; 113 fastcgi_param SERVER_ADDR $server_addr;
127 fastcgi_param SERVER_PORT $server_port; 114 fastcgi_param SERVER_PORT $server_port;
128 fastcgi_param SERVER_NAME $server_name; 115 fastcgi_param SERVER_NAME $server_name;
129 } 116 }
130 } 117 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld