Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 set $browser "firefox"; | |
19 if ($http_user_agent ~ \bChrome/\d+) { | 20 if ($http_user_agent ~ \bChrome/\d+) { |
20 set $browser "chrome"; | 21 set $browser "chrome"; |
21 } | 22 } |
22 if ($http_user_agent ~ \bPresto/\d+) { | 23 if ($http_user_agent ~ \bPresto/\d+) { |
23 set $browser "opera"; | 24 set $browser "opera"; |
24 } | 25 } |
25 if ($http_user_agent !~ \bChrome/\d+) { | 26 if ($http_user_agent ~ \bAndroid\s.*\bAppleWebKit/\d+) { |
Wladimir Palant
2012/12/19 11:16:39
Actually, it wasn't broken before - a rewrite stat
Felix Dahlke
2012/12/19 11:45:30
Right, didn't think there. I presumed this was jus
| |
26 set $browser "firefox"; | 27 set $browser "android"; |
27 } | 28 } |
28 | 29 |
29 if ($arg_a ~ ^(view|show)?$) { | 30 if ($arg_a ~ ^(view|show)?$) { |
30 rewrite ^/(index\.html)?$ /$preferredLang/#$browser redirect; | 31 rewrite ^/(index\.html)?$ /$preferredLang/$browser redirect; |
31 rewrite ^/(\w\w(_\w\w)?)$ /$1/#$browser redirect; | 32 rewrite ^/(\w\w(_\w\w)?)$ /$1/$browser redirect; |
32 } | 33 } |
33 | 34 |
34 rewrite ^/(\w\w(_\w\w)?)/(firefox|chrome|opera) /$1/#$3 permanent; | |
Wladimir Palant
2012/12/19 11:16:39
Also android.
| |
35 rewrite ^/(\w\w(_\w\w)?)/installation$ /$1/ permanent; | 35 rewrite ^/(\w\w(_\w\w)?)/installation$ /$1/ permanent; |
Felix Dahlke
2012/12/19 10:32:09
This one I did fix while I was at it.
Wladimir Palant
2012/12/19 11:16:39
Actually, I think that zh_CN was only added after
| |
36 rewrite ^/anwiki/(.*) /$1 permanent; | 36 rewrite ^/anwiki/(.*) /$1 permanent; |
37 | 37 |
38 if (-f $request_filename) { | 38 if (-f $request_filename) { |
39 break; | 39 break; |
40 } | 40 } |
41 if (-d $request_filename) { | 41 if (-d $request_filename) { |
42 break; | 42 break; |
43 } | 43 } |
44 | 44 |
45 set $static_uri $uri; | |
46 if ($uri ~ ^/(\w\w(_\w\w)?)/(firefox|chrome|opera|android)) { | |
47 set $static_uri "/$1/"; | |
48 set $browser $3; | |
49 } | |
45 set $static ""; | 50 set $static ""; |
46 if (-f "$document_root/static$uri") { | 51 if (-f "$document_root/static$static_uri") { |
47 set $static "ok"; | 52 set $static "ok"; |
48 } | 53 } |
49 if (-d "$document_root/static$uri") { | 54 if (-d "$document_root/static$static_uri") { |
50 set $static "ok"; | 55 set $static "ok"; |
51 } | 56 } |
52 set $static "$static!$arg_a!$cookie_anwiki_anwsesscode"; | 57 set $static "$static!$arg_a!$cookie_anwiki_anwsesscode"; |
53 if ($static ~ ^ok!(view|show)?!$) { | 58 if ($static ~ ^ok!(view|show)?!$) { |
54 rewrite (.*) /static$1 last; | 59 rewrite ^ /static$static_uri?browser=$browser last; |
55 } | 60 } |
56 | 61 |
62 rewrite ^/(\w\w(_\w\w)?)/(firefox|chrome|opera|android) /index.php?p=$1&brow ser=$3 last; | |
57 rewrite ^/(.*) /index.php?p=$1 last; | 63 rewrite ^/(.*) /index.php?p=$1 last; |
58 } | 64 } |
59 | 65 |
60 location /static/ { | 66 location /static/ { |
61 index index; | 67 index index; |
62 internal; | 68 internal; |
63 types { | 69 types { |
64 image/png png; | 70 image/png png; |
65 text/xml xml; | 71 text/xml xml; |
66 text/css css; | 72 text/css css; |
67 } | 73 } |
68 default_type text/html; | 74 default_type text/html; |
69 charset utf-8; | 75 charset utf-8; |
70 | 76 |
71 set $browserClass ' nongecko'; | 77 if ($arg_browser) { |
72 if ($http_user_agent ~ \bGecko/\d+) { | 78 set $browser_class ' class="$arg_browser"'; |
73 set $browserClass ' gecko'; | |
74 } | 79 } |
75 if ($http_user_agent ~ \bK-Meleon\b) { | 80 sub_filter ' id="content"' ' id="content"$browser_class'; |
76 set $browserClass ' kmeleon'; | |
77 } | |
78 if ($http_user_agent ~ \bChrome/\d+) { | |
79 set $browserClass ' chrome'; | |
80 } | |
81 if ($http_user_agent ~ \bPresto/\d+) { | |
82 set $browserClass ' opera'; | |
83 } | |
84 sub_filter ' id="content" class="multicolumn"' ' id="content" class="multi column$browserClass"'; | |
85 } | 81 } |
86 | 82 |
87 | 83 |
88 location ~ \.php$ { | 84 location ~ \.php$ { |
89 client_max_body_size 8m; | 85 client_max_body_size 8m; |
90 | 86 |
91 set $browserClass ' nongecko'; | 87 if ($arg_browser) { |
92 if ($http_user_agent ~ \bGecko/\d+) { | 88 set $browser_class ' class="$arg_browser"'; |
93 set $browserClass ' gecko'; | |
94 } | 89 } |
95 if ($http_user_agent ~ \bK-Meleon\b) { | 90 sub_filter ' id="content"' ' id="content"$browser_class'; |
96 set $browserClass ' kmeleon'; | |
97 } | |
98 if ($http_user_agent ~ \bChrome/\d+) { | |
99 set $browserClass ' chrome'; | |
100 } | |
101 if ($http_user_agent ~ \bPresto/\d+) { | |
102 set $browserClass ' opera'; | |
103 } | |
104 sub_filter ' id="content" class="multicolumn"' ' id="content" class="multico lumn$browserClass"'; | |
105 | 91 |
106 fastcgi_pass unix:/tmp/php-fastcgi.sock; | 92 fastcgi_pass unix:/tmp/php-fastcgi.sock; |
107 fastcgi_index index.php; | 93 fastcgi_index index.php; |
108 | 94 |
109 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; |
110 | 96 |
111 fastcgi_param QUERY_STRING $query_string; | 97 fastcgi_param QUERY_STRING $query_string; |
112 fastcgi_param REQUEST_METHOD $request_method; | 98 fastcgi_param REQUEST_METHOD $request_method; |
113 fastcgi_param CONTENT_TYPE $content_type; | 99 fastcgi_param CONTENT_TYPE $content_type; |
114 fastcgi_param CONTENT_LENGTH $content_length; | 100 fastcgi_param CONTENT_LENGTH $content_length; |
115 | 101 |
116 fastcgi_param SCRIPT_NAME $fastcgi_script_name; | 102 fastcgi_param SCRIPT_NAME $fastcgi_script_name; |
117 fastcgi_param REQUEST_URI $request_uri; | 103 fastcgi_param REQUEST_URI $request_uri; |
118 fastcgi_param DOCUMENT_URI $document_uri; | 104 fastcgi_param DOCUMENT_URI $document_uri; |
119 fastcgi_param DOCUMENT_ROOT $document_root; | 105 fastcgi_param DOCUMENT_ROOT $document_root; |
120 fastcgi_param SERVER_PROTOCOL $server_protocol; | 106 fastcgi_param SERVER_PROTOCOL $server_protocol; |
121 | 107 |
122 fastcgi_param GATEWAY_INTERFACE CGI/1.1; | 108 fastcgi_param GATEWAY_INTERFACE CGI/1.1; |
123 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; | 109 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; |
124 | 110 |
125 fastcgi_param REMOTE_ADDR $remote_addr; | 111 fastcgi_param REMOTE_ADDR $remote_addr; |
126 fastcgi_param REMOTE_PORT $remote_port; | 112 fastcgi_param REMOTE_PORT $remote_port; |
127 fastcgi_param SERVER_ADDR $server_addr; | 113 fastcgi_param SERVER_ADDR $server_addr; |
128 fastcgi_param SERVER_PORT $server_port; | 114 fastcgi_param SERVER_PORT $server_port; |
129 fastcgi_param SERVER_NAME $server_name; | 115 fastcgi_param SERVER_NAME $server_name; |
130 } | 116 } |
131 } | 117 } |
LEFT | RIGHT |