Index: modules/web/templates/site.conf.erb |
=================================================================== |
rename from modules/web/templates/site.erb |
rename to modules/web/templates/site.conf.erb |
--- a/modules/web/templates/site.erb |
+++ b/modules/web/templates/site.conf.erb |
@@ -1,134 +1,78 @@ |
-server |
+expires 1d; |
+ |
+root /var/www/<%= vhost %>; |
+index index; |
+default_type text/html; |
+ |
+<% if custom_config %> |
+ <%= custom_config %> |
+<% end %> |
+ |
+# Match Accept-Language header against available languages |
+ |
+set $preferredLang ""; |
+if ($http_accept_language ~ ^(\w\w)-(\w\w)\b) |
{ |
- <% if is_default %> |
- listen 80 default_server; |
- listen [::]:80 default_server; |
- <% else %> |
- listen 80; |
- listen [::]:80; |
- <% end %> |
- |
- server_name '<%= vhost %>'; |
- |
- location / |
- { |
- rewrite (.*) https://<%= vhost %>$1 permanent; |
- } |
+ set $preferrredLang $1_$2; |
+} |
+if (!-f $document_root/$preferredLang/index) |
+{ |
+ set $preferredLang ""; |
} |
-server |
+set $temp "$preferredLang|$http_accept_language"; |
+if ($temp ~ ^\|(\w\w)\b) |
{ |
- <% if is_default %> |
- listen 443 ssl default_server; |
- listen [::]:443 ssl default_server; |
- <% else %> |
- listen 443 ssl; |
- listen [::]:443 ssl; |
- <% end %> |
- |
- server_name '<%= vhost %>'; |
- |
- ssl_certificate sites-available/adblockplus.org_sslcert.pem; |
- ssl_certificate_key sites-available/adblockplus.org_sslcert.key; |
- |
- expires 1d; |
- |
- root /var/www/<%= vhost %>; |
- index index; |
- default_type text/html; |
- |
- <% if custom_config %> |
- <%= custom_config %> |
- <% end %> |
- |
- # Match Accept-Language header against available languages |
- |
+ set $preferredLang $1; |
+} |
+if (!-f $document_root/$preferredLang/index) |
+{ |
set $preferredLang ""; |
- if ($http_accept_language ~ ^(\w\w)-(\w\w)\b) |
- { |
- set $preferrredLang $1_$2; |
- } |
- if (!-f $document_root/$preferredLang/index) |
- { |
- set $preferredLang ""; |
- } |
- |
- set $temp "$preferredLang|$http_accept_language"; |
- if ($temp ~ ^\|(\w\w)\b) |
- { |
- set $preferredLang $1; |
- } |
- if (!-f $document_root/$preferredLang/index) |
- { |
- set $preferredLang ""; |
- } |
- |
- if ($preferredLang = "") |
- { |
- set $preferredLang "en"; |
- } |
- |
- # Always redirect server root |
- |
- rewrite ^/$ /$preferredLang/ last; |
- |
- # Don't do anything if requested file exists |
- |
- if (-f $request_filename) |
- { |
- break; |
- } |
- if (-d $request_filename) |
- { |
- break; |
- } |
- |
- # Redirect canonical URLs to language-specific versions |
- |
- set $canonical $uri; |
- if ($canonical ~ ^(.*?)\?) |
- { |
- set $canonical $1; |
- } |
- |
- if (-f $document_root/$preferredLang$canonical) |
- { |
- rewrite ^ /$preferredLang$canonical last; |
- } |
- if (-f $document_root/en$canonical) |
- { |
- rewrite ^ /en$canonical last; |
- } |
- |
- <% if @multiplexer_locations %> |
- <% @multiplexer_locations.each do |location| %> |
- location <%= location %> |
- { |
- fastcgi_pass unix:/tmp/multiplexer-fastcgi.sock; |
- include /etc/nginx/fastcgi_params; |
- } |
- <% end %> |
- <% end %> |
} |
-<% if @aliases %> |
- <% @aliases.each do |vhost_alias| %> |
- server |
- { |
- listen 80; |
- listen [::]:80; |
- listen 443 ssl; |
- listen [::]:443 ssl; |
+if ($preferredLang = "") |
+{ |
+ set $preferredLang "en"; |
+} |
- server_name '<%= vhost_alias %>'; |
+# Always redirect server root |
- ssl_certificate sites-available/adblockplus.org_sslcert.pem; |
- ssl_certificate_key sites-available/adblockplus.org_sslcert.key; |
+rewrite ^/$ /$preferredLang/ last; |
- location / |
- { |
- rewrite .* https://<%= vhost %>/ redirect; |
- } |
- } |
+# Don't do anything if requested file exists |
+ |
+if (-f $request_filename) |
+{ |
+ break; |
+} |
+if (-d $request_filename) |
+{ |
+ break; |
+} |
+ |
+# Redirect canonical URLs to language-specific versions |
+ |
+set $canonical $uri; |
+if ($canonical ~ ^(.*?)\?) |
+{ |
+ set $canonical $1; |
+} |
+ |
+if (-f $document_root/$preferredLang$canonical) |
+{ |
+ rewrite ^ /$preferredLang$canonical last; |
+} |
+if (-f $document_root/en$canonical) |
+{ |
+ rewrite ^ /en$canonical last; |
+} |
+ |
+<% if @multiplexer_locations %> |
+ <% @multiplexer_locations.each do |location| %> |
+ location <%= location %> |
+ { |
+ fastcgi_pass unix:/tmp/multiplexer-fastcgi.sock; |
+ include /etc/nginx/fastcgi_params; |
+ } |
<% end %> |
<% end %> |