| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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"; | |
| 36 } | 48 } |
| 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 ""; | 49 set $static ""; |
| 45 if (-f "$document_root/static$uri") { | 50 if (-f "$document_root/static$static_uri") { |
| 46 set $static "ok"; | 51 set $static "ok"; |
| 47 } | 52 } |
| 48 if (-d "$document_root/static$uri") { | 53 if (-d "$document_root/static$static_uri") { |
| 49 set $static "ok"; | 54 set $static "ok"; |
| 50 } | 55 } |
| 51 set $static "$static!$arg_a!$cookie_anwiki_anwsesscode"; | 56 set $static "$static!$arg_a!$cookie_anwiki_anwsesscode"; |
| 52 if ($static ~ ^ok!(view|show)?!$) { | 57 if ($static ~ ^ok!(view|show)?!$) { |
| 53 rewrite (.*) /static$1 last; | 58 rewrite ^/(\w\w(_\w\w)?)/(firefox|chrome|opera|android) /static/$1/?browse r=$3 last; |
| 59 rewrite (.*) /static/$1 last; | |
|
Wladimir Palant
2012/12/19 16:41:56
Do we need the special case and code duplication f
Felix Dahlke
2012/12/19 20:01:23
You're right, changed that part. I was a bit worri
| |
| 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 sub_filter ' id="content"' ' id="content" class="$arg_browser"'; |
|
Wladimir Palant
2012/12/19 16:41:56
Note that this will affect all pages, not just the
Felix Dahlke
2012/12/19 20:01:23
I've tried to put that sub_filter inside an if, bu
| |
| 71 if ($http_user_agent ~ \bGecko/\d+) { | |
| 72 set $browserClass ' gecko'; | |
| 73 } | |
| 74 if ($http_user_agent ~ \bK-Meleon\b) { | |
| 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 } | 78 } |
| 85 | 79 |
| 86 | 80 |
| 87 location ~ \.php$ { | 81 location ~ \.php$ { |
| 88 client_max_body_size 8m; | 82 client_max_body_size 8m; |
| 89 | 83 |
| 90 set $browserClass ' nongecko'; | |
| 91 if ($http_user_agent ~ \bGecko/\d+) { | |
| 92 set $browserClass ' gecko'; | |
| 93 } | |
| 94 if ($http_user_agent ~ \bK-Meleon\b) { | |
| 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 | |
| 105 fastcgi_pass unix:/tmp/php-fastcgi.sock; | 84 fastcgi_pass unix:/tmp/php-fastcgi.sock; |
| 106 fastcgi_index index.php; | 85 fastcgi_index index.php; |
| 107 | 86 |
| 108 fastcgi_param SCRIPT_FILENAME /var/www/adblockplus.org/phproot$fastcgi_scrip t_name; | 87 fastcgi_param SCRIPT_FILENAME /var/www/adblockplus.org/phproot$fastcgi_scrip t_name; |
| 109 | 88 |
| 110 fastcgi_param QUERY_STRING $query_string; | 89 fastcgi_param QUERY_STRING $query_string; |
| 111 fastcgi_param REQUEST_METHOD $request_method; | 90 fastcgi_param REQUEST_METHOD $request_method; |
| 112 fastcgi_param CONTENT_TYPE $content_type; | 91 fastcgi_param CONTENT_TYPE $content_type; |
| 113 fastcgi_param CONTENT_LENGTH $content_length; | 92 fastcgi_param CONTENT_LENGTH $content_length; |
| 114 | 93 |
| 115 fastcgi_param SCRIPT_NAME $fastcgi_script_name; | 94 fastcgi_param SCRIPT_NAME $fastcgi_script_name; |
| 116 fastcgi_param REQUEST_URI $request_uri; | 95 fastcgi_param REQUEST_URI $request_uri; |
| 117 fastcgi_param DOCUMENT_URI $document_uri; | 96 fastcgi_param DOCUMENT_URI $document_uri; |
| 118 fastcgi_param DOCUMENT_ROOT $document_root; | 97 fastcgi_param DOCUMENT_ROOT $document_root; |
| 119 fastcgi_param SERVER_PROTOCOL $server_protocol; | 98 fastcgi_param SERVER_PROTOCOL $server_protocol; |
| 120 | 99 |
| 121 fastcgi_param GATEWAY_INTERFACE CGI/1.1; | 100 fastcgi_param GATEWAY_INTERFACE CGI/1.1; |
| 122 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; | 101 fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; |
| 123 | 102 |
| 124 fastcgi_param REMOTE_ADDR $remote_addr; | 103 fastcgi_param REMOTE_ADDR $remote_addr; |
| 125 fastcgi_param REMOTE_PORT $remote_port; | 104 fastcgi_param REMOTE_PORT $remote_port; |
| 126 fastcgi_param SERVER_ADDR $server_addr; | 105 fastcgi_param SERVER_ADDR $server_addr; |
| 127 fastcgi_param SERVER_PORT $server_port; | 106 fastcgi_param SERVER_PORT $server_port; |
| 128 fastcgi_param SERVER_NAME $server_name; | 107 fastcgi_param SERVER_NAME $server_name; |
| 108 | |
| 109 sub_filter ' id="content"' ' id="content" class="$arg_browser"'; | |
|
Wladimir Palant
2012/12/19 16:41:56
Nit: you probably should leave sub_filter in the s
Felix Dahlke
2012/12/19 20:01:23
Done. Thought it made more sense down there but yo
| |
| 129 } | 110 } |
| 130 } | 111 } |
| OLD | NEW |