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

Unified Diff: modules/web/templates/site.conf.erb

Issue 5734493784637440: Issue 245 - Unify SSL configuration for all servers (Closed)
Patch Set: Created April 2, 2014, 2:05 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« modules/trac/files/site.conf ('K') | « modules/web/templates/global.conf.erb ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 %>
« modules/trac/files/site.conf ('K') | « modules/web/templates/global.conf.erb ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld