]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/apache.erb
Add support for private mediawiki sites
[chef.git] / cookbooks / mediawiki / templates / default / apache.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 <VirtualHost *:80>
4   ServerName <%= @name %>
5 <% @aliases.each do |alias_name| -%>
6   ServerAlias <%= alias_name %>
7 <% end -%>
8
9   ServerAdmin webmaster@openstreetmap.org
10
11   CustomLog /var/log/apache2/<%= @name %>-access.log combined
12   ErrorLog /var/log/apache2/<%= @name %>-error.log
13
14   DocumentRoot <%= @directory %>
15
16   php_admin_value open_basedir <%= @directory %>/:/usr/share/php/:/tmp/
17   #php_admin_value disable_functions "exec,shell_exec,system,passthru,popen,proc_open"
18   php_value memory_limit 128M
19   php_value max_execution_time 240
20   php_value upload_max_filesize 70M
21   php_value post_max_size 100M
22
23   RedirectMatch 301 ^/$                           /wiki/Main_Page
24
25   #Historical Compatibility Links
26   RedirectMatch 301 ^/index\.php$                 /w/index.php
27   RedirectMatch 301 ^/index\.php/(.*)$            /wiki/$1
28   RedirectMatch 301 ^/skins/(.*)$                 /w/skins/$1
29   RedirectMatch 301 ^/images/(.*)$                /w/images/$1
30   RedirectMatch 301 ^/api\.php$                   /w/api.php
31   RedirectMatch 301 ^/opensearch_desc\.php$       /w/opensearch_desc.php
32
33   Alias /wiki <%= @mediawiki[:directory] %>/index.php
34
35   #Support /pagename -> /wiki/pagename
36   RewriteEngine on
37   RewriteCond %{REQUEST_URI} !^/w/
38   RewriteCond %{REQUEST_URI} !^/wiki/
39   RewriteCond %{REQUEST_URI} !^/index\.php
40   RewriteCond %{REQUEST_URI} !^/skins/
41   RewriteCond %{REQUEST_URI} !^/images/
42   RewriteCond %{REQUEST_URI} !^/api\.php$
43   RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
44   RewriteCond %{REQUEST_URI} !^/server-status
45   RewriteCond %{LA-U:REQUEST_FILENAME} !-f
46   RewriteCond %{LA-U:REQUEST_FILENAME} !-d
47   RewriteRule ^/(.*) /wiki/$1 [R,L]
48
49   <Directory <%= @directory %>>
50     Options -Indexes
51 <% if node[:lsb][:release].to_f >= 14.04 -%>
52     Require all granted
53 <% end -%>
54   </Directory>
55
56   <Directory <%= @mediawiki[:directory] %>/images/>
57     # No php execution in the upload area
58     php_admin_flag engine off
59     Options -ExecCGI -Includes -Indexes
60     AllowOverride None
61   </Directory>
62
63   <Directory <%= @mediawiki[:directory] %>/images/thumb/>
64     RewriteEngine on
65
66     RewriteCond %{REQUEST_FILENAME} !-f
67     RewriteCond %{REQUEST_FILENAME} !-d
68     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]
69
70     RewriteCond %{REQUEST_FILENAME} !-f
71     RewriteCond %{REQUEST_FILENAME} !-d
72     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]
73
74     RewriteCond %{REQUEST_FILENAME} !-f
75     RewriteCond %{REQUEST_FILENAME} !-d
76     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
77
78     RewriteCond %{REQUEST_FILENAME} !-f
79     RewriteCond %{REQUEST_FILENAME} !-d
80     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]
81   </Directory>
82
83   <Directory <%= @mediawiki[:directory] %>/maintenance/>
84 <% if node[:lsb][:release].to_f >= 14.04 -%>
85     Require all denied
86 <% else -%>
87     Order allow,deny
88     Deny from all
89 <% end -%>
90   </Directory>
91
92   <Files <%= @mediawiki[:directory] %>/LocalSettings.php>
93 <% if node[:lsb][:release].to_f >= 14.04 -%>
94     Require all denied
95 <% else -%>
96     Order allow,deny
97     Deny from all
98 <% end -%>
99   </Files>
100
101   <Directory <%= @mediawiki[:directory] %>/images/>
102     Options -ExecCGI -Includes -Indexes
103     AllowOverride None
104     AddType text/plain .html .htm .shtml
105     php_admin_flag engine off
106   </Directory>
107
108   <Directory <%= @mediawiki[:directory] %>/cache/>
109     Options -ExecCGI -Includes -Indexes
110     AllowOverride None
111     AddType text/plain .html .htm .shtml
112     php_admin_flag engine off
113   </Directory>
114
115   <Directory ~ "\.svn">
116 <% if node[:lsb][:release].to_f >= 14.04 -%>
117     Require all denied
118 <% else -%>
119     Order allow,deny
120     Deny from all
121 <% end -%>
122   </Directory>
123
124   <Directory ~ "\.git">
125 <% if node[:lsb][:release].to_f >= 14.04 -%>
126     Require all denied
127 <% else -%>
128     Order allow,deny
129     Deny from all
130 <% end -%>
131   </Directory>
132
133   <Files ~ "~$">
134 <% if node[:lsb][:release].to_f >= 14.04 -%>
135     Require all denied
136 <% else -%>
137     Order allow,deny
138     Deny from all
139 <% end -%>
140   </Files>
141 </VirtualHost>
142 <% if @mediawiki[:enable_ssl] -%>
143 <VirtualHost *:443>
144   ServerName <%= @name %>
145 <% @aliases.each do |alias_name| -%>
146   ServerAlias <%= alias_name %>
147 <% end -%>
148
149   ServerAdmin webmaster@openstreetmap.org
150
151   SSLEngine on
152
153   CustomLog /var/log/apache2/<%= @name %>-secure-access.log combined
154   ErrorLog /var/log/apache2/<%= @name %>-secure-error.log
155
156   DocumentRoot <%= @directory %>
157
158   php_admin_value open_basedir <%= @directory %>/:/usr/share/php/:/tmp/
159   #php_admin_value disable_functions "exec,shell_exec,system,passthru,popen,proc_open"
160   php_value memory_limit 128M
161   php_value max_execution_time 240
162   php_value upload_max_filesize 70M
163   php_value post_max_size 100M
164
165   RedirectMatch 301 ^/$                           /wiki/Main_Page
166
167   #Historical Compatibility Links
168   RedirectMatch 301 ^/index\.php$                 /w/index.php
169   RedirectMatch 301 ^/index\.php/(.*)$            /wiki/$1
170   RedirectMatch 301 ^/skins/(.*)$                 /w/skins/$1
171   RedirectMatch 301 ^/images/(.*)$                /w/images/$1
172   RedirectMatch 301 ^/api\.php$                   /w/api.php
173   RedirectMatch 301 ^/opensearch_desc\.php$       /w/opensearch_desc.php
174
175   Alias /wiki <%= @mediawiki[:directory] %>/index.php
176
177   #Support /pagename -> /wiki/pagename
178   RewriteEngine on
179   RewriteCond %{REQUEST_URI} !^/w/
180   RewriteCond %{REQUEST_URI} !^/wiki/
181   RewriteCond %{REQUEST_URI} !^/index\.php
182   RewriteCond %{REQUEST_URI} !^/skins/
183   RewriteCond %{REQUEST_URI} !^/images/
184   RewriteCond %{REQUEST_URI} !^/api\.php$
185   RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
186   RewriteCond %{REQUEST_URI} !^/server-status
187   RewriteCond %{LA-U:REQUEST_FILENAME} !-f
188   RewriteCond %{LA-U:REQUEST_FILENAME} !-d
189   RewriteRule ^/(.*) /wiki/$1 [R,L]
190
191   <Directory <%= @directory %>>
192     Options -Indexes
193 <% if node[:lsb][:release].to_f >= 14.04 -%>
194     Require all granted
195 <% end -%>
196   </Directory>
197
198   <Directory <%= @mediawiki[:directory] %>/images/>
199     # No php execution in the upload area
200     php_admin_flag engine off
201     Options -ExecCGI -Includes -Indexes
202     AllowOverride None
203 <% if @mediawiki[:private] -%>
204 <% if node[:lsb][:release].to_f >= 14.04 -%>
205     Require all denied
206 <% else -%>
207     Order allow,deny
208     Deny from all
209 <% end -%>
210 <% end -%>
211   </Directory>
212
213   <Directory <%= @mediawiki[:directory] %>/images/thumb/>
214     RewriteEngine on
215
216     RewriteCond %{REQUEST_FILENAME} !-f
217     RewriteCond %{REQUEST_FILENAME} !-d
218     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
219
220     RewriteCond %{REQUEST_FILENAME} !-f
221     RewriteCond %{REQUEST_FILENAME} !-d
222     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]
223   </Directory>
224
225   <Directory <%= @mediawiki[:directory] %>/maintenance/>
226 <% if node[:lsb][:release].to_f >= 14.04 -%>
227     Require all denied
228 <% else -%>
229     Order allow,deny
230     Deny from all
231 <% end -%>
232   </Directory>
233
234   <Files <%= @mediawiki[:directory] %>/LocalSettings.php>
235 <% if node[:lsb][:release].to_f >= 14.04 -%>
236     Require all denied
237 <% else -%>
238     Order allow,deny
239     Deny from all
240 <% end -%>
241   </Files>
242
243   <Directory <%= @mediawiki[:directory] %>/images/>
244     Options -ExecCGI -Includes -Indexes
245     AllowOverride None
246     AddType text/plain .html .htm .shtml
247     php_admin_flag engine off
248   </Directory>
249
250   <Directory <%= @mediawiki[:directory] %>/cache/>
251     Options -ExecCGI -Includes -Indexes
252     AllowOverride None
253     AddType text/plain .html .htm .shtml
254     php_admin_flag engine off
255   </Directory>
256
257   <Directory ~ "\.svn">
258 <% if node[:lsb][:release].to_f >= 14.04 -%>
259     Require all denied
260 <% else -%>
261     Order allow,deny
262     Deny from all
263 <% end -%>
264   </Directory>
265
266   <Directory ~ "\.git">
267 <% if node[:lsb][:release].to_f >= 14.04 -%>
268     Require all denied
269 <% else -%>
270     Order allow,deny
271     Deny from all
272 <% end -%>
273   </Directory>
274
275   <Files ~ "~$">
276 <% if node[:lsb][:release].to_f >= 14.04 -%>
277     Require all denied
278 <% else -%>
279     Order allow,deny
280     Deny from all
281 <% end -%>
282   </Files>
283 </VirtualHost>
284 <% end -%>