Bring dev.osm.org under chef control and SSL enable it
authorTom Hughes <tom@compton.nu>
Thu, 4 Jan 2018 18:31:52 +0000 (18:31 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 4 Jan 2018 18:42:13 +0000 (18:42 +0000)
cookbooks/dev/recipes/default.rb
cookbooks/dev/templates/default/apache.dev.erb [new file with mode: 0644]
cookbooks/dev/templates/default/dev.html.erb [new file with mode: 0644]

index bdcec26..4ac5848 100644 (file)
@@ -98,6 +98,28 @@ file "/etc/php/7.0/fpm/pool.d/www.conf" do
   notifies :reload, "service[php7.0-fpm]"
 end
 
+directory "/srv/dev.openstreetmap.org" do
+  owner "root"
+  group "root"
+  mode 0o755
+end
+
+template "/srv/dev.openstreetmap.org/index.html" do
+  source "dev.html.erb"
+  owner "root"
+  group "root"
+  mode 0o644
+end
+
+ssl_certificate "dev.openstreetmap.org" do
+  domains "dev.openstreetmap.org"
+  notifies :reload, "service[apache2]"
+end
+
+apache_site "dev.openstreetmap.org" do
+  template "apache.dev.erb"
+end
+
 package "phppgadmin"
 
 template "/etc/phppgadmin/config.inc.php" do
diff --git a/cookbooks/dev/templates/default/apache.dev.erb b/cookbooks/dev/templates/default/apache.dev.erb
new file mode 100644 (file)
index 0000000..71b73b9
--- /dev/null
@@ -0,0 +1,35 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+<VirtualHost *:443>
+       ServerName dev.openstreetmap.org
+       ServerAdmin webmaster@openstreetmap.org
+
+       SSLEngine on
+       SSLCertificateFile /etc/ssl/certs/dev.openstreetmap.org.pem
+       SSLCertificateKeyFile /etc/ssl/private/dev.openstreetmap.org.key
+
+       CustomLog /var/log/apache2/dev.openstreetmap.org-access.log combined
+       ErrorLog /var/log/apache2/dev.openstreetmap.org-error.log
+
+       DocumentRoot /srv/dev.openstreetmap.org
+
+       RewriteEngine on
+       RewriteCond %{REQUEST_URI} ^/~([^/]*)(/.*)?$
+       RewriteCond /home/%1/public_html -d
+       RewriteRule ^/~([^/]*)(/.*)?$ https://$1.dev.openstreetmap.org$2 [NS,R=307]
+</VirtualHost>
+
+<VirtualHost *:80>
+       ServerName dev.openstreetmap.org
+       ServerAdmin webmaster@openstreetmap.org
+
+       CustomLog /var/log/apache2/dev.openstreetmap.org-access.log combined
+       ErrorLog /var/log/apache2/dev.openstreetmap.org-error.log
+
+       RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
+       RedirectPermanent / https://dev.openstreetmap.org/
+</VirtualHost>
+
+<Directory /srv/dev.openstreetmap.org>
+       Require all granted
+</Directory>
diff --git a/cookbooks/dev/templates/default/dev.html.erb b/cookbooks/dev/templates/default/dev.html.erb
new file mode 100644 (file)
index 0000000..3b4ab2f
--- /dev/null
@@ -0,0 +1,10 @@
+<html>
+<body>
+You've reached errol, the OpenStreetMap dev server. <br />
+<dl>
+<dt>If you are a user...</dt>
+<dd>You probably want <a href="https://www.openstreetmap.org/">OpenStreetMap</a> itself.</dd>
+<dt>If you are a developer...</dt>
+<dd>You might be interested in <a href="https://apis.dev.openstreetmap.org/">live instances</a> of various <a href="https://wiki.openstreetmap.org/index.php/The_Rails_Port#Installation_on_Debian">Rails Port</a> code branches in <a href="https://svn.openstreetmap.org/sites/rails_port_branches/">SVN</a> for testing clients against.</dd>
+</body>
+</html>