summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2011-02-22 22:59:40 +0100
committermh <mh@immerda.ch>2011-02-22 22:59:40 +0100
commitf14fd057987b5489228a40444c3a101768c5b6bb (patch)
tree6822b37970897305924f5e11b1d7ee49a90ee9de /templates
parentea3ebee7153660f809d7f26224e7282f97029743 (diff)
first way to a unified partial based vhost template
Diffstat (limited to 'templates')
-rw-r--r--templates/vhosts/default.erb16
-rw-r--r--templates/vhosts/partials/header_default.erb13
-rw-r--r--templates/vhosts/partials/logs.erb14
3 files changed, 43 insertions, 0 deletions
diff --git a/templates/vhosts/default.erb b/templates/vhosts/default.erb
new file mode 100644
index 0000000..9e16337
--- /dev/null
+++ b/templates/vhosts/default.erb
@@ -0,0 +1,16 @@
+<%- [:normal,:ssl].each do |vhost_part| %>
+<VirtualHost *:<%= vhost_part == :ssl ? '443' : '80' >
+
+ <%= scope.function_template('apache/vhost/partials/header_default.erb') %>
+ <%= scope.function_template('apache/vhost/partials/logs.erb') %>
+
+ <%- if ssl_mode == 'force' && vhost_part == :ssl %>
+ RewriteEngine On
+ RewriteCond %{HTTPS} !=on
+ RewriteRule (.*) https://%{SERVER_NAME}$1 [R=permanent,L]
+ <%- else %>
+ <%= scope.function_template(template_partial) %>
+ <%- end %>
+
+</VirtualHost>
+<%- end %>
diff --git a/templates/vhosts/partials/header_default.erb b/templates/vhosts/partials/header_default.erb
new file mode 100644
index 0000000..13eeea1
--- /dev/null
+++ b/templates/vhosts/partials/header_default.erb
@@ -0,0 +1,13 @@
+ Include include.d/defaults.inc
+ <%- if vhost_part == :ssl %>
+ Include include.d/ssl_defaults.inc
+ <%- end %>
+
+ ServerName <%= servername %>
+ <%- unless serveralias.to_s.empty? then -%>
+ ServerAlias <%= serveralias %>
+ <%- end -%>
+ <%- unless server_admin.to_s.empty? or server_admin.to_s == 'absent' then -%>
+ ServerAdmin <%= server_admin %>
+ <%- end -%>
+ DocumentRoot <%= documentroot %>/
diff --git a/templates/vhosts/partials/logs.erb b/templates/vhosts/partials/logs.erb
new file mode 100644
index 0000000..b61018c
--- /dev/null
+++ b/templates/vhosts/partials/logs.erb
@@ -0,0 +1,14 @@
+ <%- case logmode.to_s
+ when 'nologs' -%>
+ ErrorLog /dev/null
+ CustomLog /dev/null
+ <%- when 'semianonym' -%>
+ ErrorLog <%= logdir %>/error_log
+ CustomLog <%= logdir %>/access_log noip
+ <%- when 'anonym' -%>
+ ErrorLog /dev/null
+ CustomLog <%= logdir %>/access_log noip
+ <%- else -%>
+ ErrorLog <%= logdir %>/error_log
+ CustomLog <%= logdir %>/access_log combined
+ <%- end -%>