From ea7e1d5cdc6e87ac1216f1e3837809e712028338 Mon Sep 17 00:00:00 2001 From: Peter Rhoades Date: Fri, 5 Jul 2013 15:17:19 +0100 Subject: [PATCH 1/2] Changing nginx template to use try_files --- .../projects/templates/shared/nginx.conf.erb | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/modules/projects/templates/shared/nginx.conf.erb b/modules/projects/templates/shared/nginx.conf.erb index 7b0252b..7f6f1f1 100644 --- a/modules/projects/templates/shared/nginx.conf.erb +++ b/modules/projects/templates/shared/nginx.conf.erb @@ -9,30 +9,17 @@ server { server_name <%= @server_name %>; client_max_body_size 50M; - error_page 500 502 503 504 /50x.html; - if ($host ~* "www") { - rewrite ^(.*)$ http://<%= @server_name %>$1 permanent; - break; - } - location = /50x.html { root html; } - - location / { - if (-f $request_filename/index.html) { - rewrite (.*) $1/index.html break; - } - - if (-f $request_filename.html) { - rewrite (.*) $1.html break; - } - - if (!-f $request_filename) { - proxy_pass http://<%= @server_name %>; - break; - } + + try_files $uri/index.html $uri @<%= @server_name %>; + location @<%= @server_name %> { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + proxy_pass http://<%= @server_name %>; } } From 38e7cc219464e81bad6606880e5448c0a672fe06 Mon Sep 17 00:00:00 2001 From: Peter Rhoades Date: Fri, 5 Jul 2013 15:46:53 +0100 Subject: [PATCH 2/2] Heavy handed removal of if block, this is not related to try_files addition --- modules/projects/templates/shared/nginx.conf.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/projects/templates/shared/nginx.conf.erb b/modules/projects/templates/shared/nginx.conf.erb index 7f6f1f1..590edbf 100644 --- a/modules/projects/templates/shared/nginx.conf.erb +++ b/modules/projects/templates/shared/nginx.conf.erb @@ -11,6 +11,11 @@ server { client_max_body_size 50M; error_page 500 502 503 504 /50x.html; + if ($host ~* "www") { + rewrite ^(.*)$ http://<%= @server_name %>$1 permanent; + break; + } + location = /50x.html { root html; }