diff --git a/templates/named_vhost.conf.erb b/templates/named_vhost.conf.erb
index 66aa99e8a344b5e81a282ec528307fb6aef5d81a..9fba8540ed70084f0d5309a9e1099d7872e1f7f6 100644
--- a/templates/named_vhost.conf.erb
+++ b/templates/named_vhost.conf.erb
@@ -92,6 +92,11 @@ NameVirtualHost <%= addr %>
 <% end -%>
 <VirtualHost <%= server_addrs.join(' ') %>>
 
-<%= vhostcfg.join("\n").gsub(/^./, '    \&') %>
+<% vhostcfg.each do |chunk|
+      # Expand tabs and indent four spaces
+      chunk = chunk.gsub(/([^\t\n]*)\t/) { $1 + " " * (8 - ($1.size % 8)) }
+-%>
+<%=   chunk.rstrip.gsub(/^./, '    \&') %>
+<% end -%>
 
 </VirtualHost>