]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/apache.erb
Generate letsencrypt certificates for mediawiki sites
[chef.git] / cookbooks / mediawiki / templates / default / apache.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2 <% @ports.each do |port| -%>
3
4 <VirtualHost *:<%= port %>>
5   ServerName <%= @name %>
6 <% @aliases.each do |alias_name| -%>
7   ServerAlias <%= alias_name %>
8 <% end -%>
9
10   ServerAdmin webmaster@openstreetmap.org
11
12 <% if port == 443 -%>
13   SSLEngine on
14
15   CustomLog /var/log/apache2/<%= @name %>-secure-access.log combined
16   ErrorLog /var/log/apache2/<%= @name %>-secure-error.log
17 <% else -%>
18   CustomLog /var/log/apache2/<%= @name %>-access.log combined
19   ErrorLog /var/log/apache2/<%= @name %>-error.log
20 <% end -%>
21
22   DocumentRoot <%= @directory %>
23
24 <% if @ssl_enabled -%>
25   RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
26 <% end -%>
27
28   php_admin_value open_basedir <%= @directory %>/:/usr/share/php/:/tmp/
29   #php_admin_value disable_functions "exec,shell_exec,system,passthru,popen,proc_open"
30   php_value memory_limit 128M
31   php_value max_execution_time 240
32   php_value upload_max_filesize 70M
33   php_value post_max_size 100M
34
35   RewriteCond %{SERVER_NAME} !=<%= @name %>
36 <% if port == 443 -%>
37   RewriteRule ^/(.*)$ https://<%= @name %>/$1 [R=permanent]
38 <% else -%>
39   RewriteRule ^/(.*)$ http://<%= @name %>/$1 [R=permanent]
40 <% end -%>
41
42   RedirectMatch 301 ^/$                           /wiki/Main_Page
43
44   #Historical Compatibility Links
45   RedirectMatch 301 ^/index\.php$                 /w/index.php
46   RedirectMatch 301 ^/index\.php/(.*)$            /wiki/$1
47   RedirectMatch 301 ^/skins/(.*)$                 /w/skins/$1
48   RedirectMatch 301 ^/images/(.*)$                /w/images/$1
49   RedirectMatch 301 ^/api\.php$                   /w/api.php
50   RedirectMatch 301 ^/opensearch_desc\.php$       /w/opensearch_desc.php
51
52   Alias /wiki <%= @directory %>/w/index.php
53
54   #Support /pagename -> /wiki/pagename
55   RewriteEngine on
56   RewriteCond %{REQUEST_URI} !^/w/
57   RewriteCond %{REQUEST_URI} !^/wiki/
58   RewriteCond %{REQUEST_URI} !^/index\.php
59   RewriteCond %{REQUEST_URI} !^/skins/
60   RewriteCond %{REQUEST_URI} !^/images/
61   RewriteCond %{REQUEST_URI} !^/api\.php$
62   RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
63   RewriteCond %{REQUEST_URI} !^/server-status
64   RewriteCond %{REQUEST_URI} !^/.well-known/
65   RewriteCond %{LA-U:REQUEST_FILENAME} !-f
66   RewriteCond %{LA-U:REQUEST_FILENAME} !-d
67   RewriteRule ^/(.*) /wiki/$1 [R,L]
68
69   <Directory <%= @directory %>>
70     Options -Indexes
71     Require all granted
72   </Directory>
73
74   <Directory <%= @directory %>/w/images/>
75     # No php execution in the upload area
76     php_admin_flag engine off
77     Options -ExecCGI -Includes -Indexes
78     AllowOverride None
79     AddType text/plain .html .htm .shtml
80 <% if @private -%>
81     Require all denied
82 <% end -%>
83   </Directory>
84
85   <Directory <%= @directory %>/w/images/thumb/>
86     RewriteEngine on
87
88     RewriteCond %{REQUEST_FILENAME} !-f
89     RewriteCond %{REQUEST_FILENAME} !-d
90     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/page([0-9]+)-([0-9]+)px-.*$ /w/thumb.php?f=$1&page=$2&width=$3 [L,QSA,B]
91
92     RewriteCond %{REQUEST_FILENAME} !-f
93     RewriteCond %{REQUEST_FILENAME} !-d
94     RewriteRule ^archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/page([0-9]+)-([0-9]+)px-.*$ /w/thumb.php?f=$1&page=$2&width=$3&archived=1 [L,QSA,B]
95
96     RewriteCond %{REQUEST_FILENAME} !-f
97     RewriteCond %{REQUEST_FILENAME} !-d
98     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
99
100     RewriteCond %{REQUEST_FILENAME} !-f
101     RewriteCond %{REQUEST_FILENAME} !-d
102     RewriteRule ^archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]
103   </Directory>
104
105   <Directory <%= @directory %>/w/maintenance/>
106     Require all denied
107   </Directory>
108
109   <Files <%= @directory %>/w/LocalSettings.php>
110     Require all denied
111   </Files>
112
113   <Directory <%= @directory %>/w/cache/>
114     Options -ExecCGI -Includes -Indexes
115     AllowOverride None
116     AddType text/plain .html .htm .shtml
117     php_admin_flag engine off
118   </Directory>
119
120   <Directory ~ "\.svn">
121     Require all denied
122   </Directory>
123
124   <Directory ~ "\.git">
125     Require all denied
126   </Directory>
127
128   <Files ~ "~$">
129     Require all denied
130   </Files>
131 </VirtualHost>
132 <% end -%>