From d22a25908460fae1d31f3047369db110a72a824b Mon Sep 17 00:00:00 2001 From: Goran Miskovic Date: Wed, 7 Aug 2013 19:21:22 +0200 Subject: [PATCH] Moved root to vhost_header. One of common pitfalls is to define root inside location block: http://wiki.nginx.org/Pitfalls#Root_inside_Location_Block --- .gitignore | 1 + templates/vhost/vhost_header.erb | 5 +++++ templates/vhost/vhost_location_directory.erb | 3 --- templates/vhost/vhost_location_fastcgi.erb | 3 --- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ba7f7787e..0bc963291 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ pkg/ .tmp/ pkg/ spec/fixtures/ +.idea/ \ No newline at end of file diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index e4d966f61..4fcfadb1a 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -5,6 +5,11 @@ server { listen [<%= ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %> ipv6only=on; <% end %> server_name <%= @rewrite_www_to_non_www ? @name.gsub(/^www\./, '') : @server_name.join(" ") %>; + +<% if defined? @www_root -%> + root <%= @www_root %>; +<% end -%> + <% if defined? auth_basic -%> auth_basic "<%= @auth_basic %>"; <% end -%> diff --git a/templates/vhost/vhost_location_directory.erb b/templates/vhost/vhost_location_directory.erb index 61705d345..3ed58ae27 100644 --- a/templates/vhost/vhost_location_directory.erb +++ b/templates/vhost/vhost_location_directory.erb @@ -2,9 +2,6 @@ <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>; <% end -%><% end -%> -<% if defined? @www_root -%> - root <%= @www_root %>; -<% end -%> <% if @try_files -%> try_files <% @try_files.each do |try| -%> <%= try %> <% end -%>; <% end -%> diff --git a/templates/vhost/vhost_location_fastcgi.erb b/templates/vhost/vhost_location_fastcgi.erb index 1306729a8..65db2b27f 100644 --- a/templates/vhost/vhost_location_fastcgi.erb +++ b/templates/vhost/vhost_location_fastcgi.erb @@ -2,9 +2,6 @@ <% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%> <%= key %> <%= value %>; <% end -%><% end -%> -<% if defined? @www_root -%> - root <%= @www_root %>; -<% end -%> <% if @fastcgi_split_path -%> fastcgi_split_path_info <%= @fastcgi_split_path %>; <% end -%>