Teach mailman cookbook about site aliases
authorGrant Slater <git@firefishy.com>
Sat, 4 Aug 2018 14:58:19 +0000 (15:58 +0100)
committerGrant Slater <git@firefishy.com>
Sat, 4 Aug 2018 14:58:19 +0000 (15:58 +0100)
cookbooks/mailman/recipes/default.rb
cookbooks/mailman/templates/default/apache.erb

index 04c2281ed3b73cf71fa8dcd2829d16945c093739..cb7d4c1a968d8bdee33702b8f4ae90eca9b495f0 100644 (file)
@@ -42,12 +42,13 @@ apache_module "expires"
 apache_module "rewrite"
 
 ssl_certificate "lists.openstreetmap.org" do
-  domains "lists.openstreetmap.org"
+  domains ["lists.openstreetmap.org", "lists.osm.org"]
   notifies :reload, "service[apache2]"
 end
 
 apache_site "lists.openstreetmap.org" do
   template "apache.erb"
+  variables :aliases => ["lists.osm.org"]
 end
 
 template "/etc/cron.daily/lists-backup" do
index f5d61b17f9e56bf9650130fdd645d063ea6a7c9b..8c22b3f1d9f7277d5f8b5113032077bf30e12b23 100644 (file)
@@ -1,65 +1,87 @@
 # DO NOT EDIT - This file is being maintained by Chef
 
 <VirtualHost *:80>
-        ServerName <%= @name %>
-        ServerAdmin postmaster@openstreetmap.org
+  ServerName <%= @name %>
+<% @aliases.each do |alias_name| -%>
+  ServerAlias <%= alias_name %>
+<% end -%>
+  ServerAdmin postmaster@openstreetmap.org
 
-        CustomLog /var/log/apache2/<%= @name %>-access.log combined
-        ErrorLog /var/log/apache2/<%= @name %>-error.log
+  CustomLog /var/log/apache2/<%= @name %>-access.log combined
+  ErrorLog /var/log/apache2/<%= @name %>-error.log
 
-        RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
-        RedirectPermanent / https://<%= @name %>/
+  RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
+  RedirectPermanent / https://<%= @name %>/
 </VirtualHost>
+<% unless @aliases.empty? -%>
 
 <VirtualHost *:443>
-       ServerName <%= @name %>
-       ServerAdmin postmaster@openstreetmap.org
-       ServerSignature On
-
-        SSLEngine on
-        SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
-        SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
-
-       CustomLog /var/log/apache2/<%= @name %>-access.log combined
-       ErrorLog /var/log/apache2/<%= @name %>-error.log
-       LogLevel warn
-
-        AddDefaultCharset off
-
-       DocumentRoot <%= @directory %>
-
-       RewriteEngine on
-
-       RewriteCond %{HTTP_REFERER} www\.mailbait\.info
-       RewriteRule . - [F,L]
-
-       RedirectMatch ^/$ /listinfo
-       RedirectMatch ^/cgi-bin/mailman/(.*)$ /$1
-
-       <Directory /var/lib/mailman/archives/>
-               Options Indexes FollowSymLinks
-               AllowOverride None
-               Require all granted
-       </Directory>
-
-       Alias /pipermail/ /var/lib/mailman/archives/public/
-       Alias /images/ /usr/share/images/mailman/
-
-       ScriptAlias /admin /usr/lib/cgi-bin/mailman/admin
-       ScriptAlias /admindb /usr/lib/cgi-bin/mailman/admindb
-       ScriptAlias /confirm /usr/lib/cgi-bin/mailman/confirm
-       ScriptAlias /create /usr/lib/cgi-bin/mailman/create
-       ScriptAlias /edithtml /usr/lib/cgi-bin/mailman/edithtml
-       ScriptAlias /listinfo /usr/lib/cgi-bin/mailman/listinfo
-       ScriptAlias /options /usr/lib/cgi-bin/mailman/options
-       ScriptAlias /private /usr/lib/cgi-bin/mailman/private
-       ScriptAlias /rmlist /usr/lib/cgi-bin/mailman/rmlist
-       ScriptAlias /roster /usr/lib/cgi-bin/mailman/roster
-       ScriptAlias /subscribe /usr/lib/cgi-bin/mailman/subscribe
-       ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/
-
-       <Location ~ "/pipermail/([^/]+)/(2004|2005|2006|2007|2008|2009|2010|2011|2012|2013|2014|2015|2016)">
-               ExpiresActive On
-               ExpiresDefault "access plus 180 days"
-       </Location>
+  ServerName <%= @aliases.first %>
+<% @aliases.drop(1).each do |alias_name| -%>
+  ServerAlias <%= alias_name %>
+<% end -%>
+  ServerAdmin webmaster@openstreetmap.org
+
+  SSLEngine on
+  SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
+  SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
+
+  CustomLog /var/log/apache2/<%= @name %>-access.log combined
+  ErrorLog /var/log/apache2/<%= @name %>-error.log
+
+  RedirectPermanent / https://<%= @name %>/
+</VirtualHost>
+<% end -%>
+
+<VirtualHost *:443>
+  ServerName <%= @name %>
+  ServerAdmin postmaster@openstreetmap.org
+  ServerSignature On
+
+  SSLEngine on
+  SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
+  SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
+
+  CustomLog /var/log/apache2/<%= @name %>-access.log combined
+  ErrorLog /var/log/apache2/<%= @name %>-error.log
+  LogLevel warn
+
+  AddDefaultCharset off
+
+  DocumentRoot <%= @directory %>
+
+  RewriteEngine on
+
+  RewriteCond %{HTTP_REFERER} www\.mailbait\.info
+  RewriteRule . - [F,L]
+
+  RedirectMatch ^/$ /listinfo
+  RedirectMatch ^/cgi-bin/mailman/(.*)$ /$1
+
+  <Directory /var/lib/mailman/archives/>
+         Options Indexes FollowSymLinks
+    AllowOverride None
+    Require all granted
+  </Directory>
+
+  Alias /pipermail/ /var/lib/mailman/archives/public/
+  Alias /images/ /usr/share/images/mailman/
+
+  ScriptAlias /admin /usr/lib/cgi-bin/mailman/admin
+  ScriptAlias /admindb /usr/lib/cgi-bin/mailman/admindb
+  ScriptAlias /confirm /usr/lib/cgi-bin/mailman/confirm
+  ScriptAlias /create /usr/lib/cgi-bin/mailman/create
+  ScriptAlias /edithtml /usr/lib/cgi-bin/mailman/edithtml
+  ScriptAlias /listinfo /usr/lib/cgi-bin/mailman/listinfo
+  ScriptAlias /options /usr/lib/cgi-bin/mailman/options
+  ScriptAlias /private /usr/lib/cgi-bin/mailman/private
+  ScriptAlias /rmlist /usr/lib/cgi-bin/mailman/rmlist
+  ScriptAlias /roster /usr/lib/cgi-bin/mailman/roster
+  ScriptAlias /subscribe /usr/lib/cgi-bin/mailman/subscribe
+  ScriptAlias /mailman/ /usr/lib/cgi-bin/mailman/
+
+  <Location ~ "/pipermail/([^/]+)/(2004|2005|2006|2007|2008|2009|2010|2011|2012|2013|2014|2015|2016|2017)">
+    ExpiresActive On
+    ExpiresDefault "access plus 180 days"
+  </Location>
 </VirtualHost>