]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/apache.erb
Eliminate duplication (and almost duplication!) in mediaiwiki config
[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   php_admin_value open_basedir <%= @directory %>/:/usr/share/php/:/tmp/
25   #php_admin_value disable_functions "exec,shell_exec,system,passthru,popen,proc_open"
26   php_value memory_limit 128M
27   php_value max_execution_time 240
28   php_value upload_max_filesize 70M
29   php_value post_max_size 100M
30
31   RedirectMatch 301 ^/$                           /wiki/Main_Page
32
33   #Historical Compatibility Links
34   RedirectMatch 301 ^/index\.php$                 /w/index.php
35   RedirectMatch 301 ^/index\.php/(.*)$            /wiki/$1
36   RedirectMatch 301 ^/skins/(.*)$                 /w/skins/$1
37   RedirectMatch 301 ^/images/(.*)$                /w/images/$1
38   RedirectMatch 301 ^/api\.php$                   /w/api.php
39   RedirectMatch 301 ^/opensearch_desc\.php$       /w/opensearch_desc.php
40
41   Alias /wiki <%= @directory %>/w/index.php
42
43   #Support /pagename -> /wiki/pagename
44   RewriteEngine on
45   RewriteCond %{REQUEST_URI} !^/w/
46   RewriteCond %{REQUEST_URI} !^/wiki/
47   RewriteCond %{REQUEST_URI} !^/index\.php
48   RewriteCond %{REQUEST_URI} !^/skins/
49   RewriteCond %{REQUEST_URI} !^/images/
50   RewriteCond %{REQUEST_URI} !^/api\.php$
51   RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
52   RewriteCond %{REQUEST_URI} !^/server-status
53   RewriteCond %{LA-U:REQUEST_FILENAME} !-f
54   RewriteCond %{LA-U:REQUEST_FILENAME} !-d
55   RewriteRule ^/(.*) /wiki/$1 [R,L]
56
57   <Directory <%= @directory %>>
58     Options -Indexes
59     Require all granted
60   </Directory>
61
62   <Directory <%= @directory %>/w/images/>
63     # No php execution in the upload area
64     php_admin_flag engine off
65     Options -ExecCGI -Includes -Indexes
66     AllowOverride None
67     AddType text/plain .html .htm .shtml
68 <% if @private -%>
69     Require all denied
70 <% end -%>
71   </Directory>
72
73   <Directory <%= @directory %>/w/images/thumb/>
74     RewriteEngine on
75
76     RewriteCond %{REQUEST_FILENAME} !-f
77     RewriteCond %{REQUEST_FILENAME} !-d
78     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]
79
80     RewriteCond %{REQUEST_FILENAME} !-f
81     RewriteCond %{REQUEST_FILENAME} !-d
82     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]
83
84     RewriteCond %{REQUEST_FILENAME} !-f
85     RewriteCond %{REQUEST_FILENAME} !-d
86     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
87
88     RewriteCond %{REQUEST_FILENAME} !-f
89     RewriteCond %{REQUEST_FILENAME} !-d
90     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]
91   </Directory>
92
93   <Directory <%= @directory %>/w/maintenance/>
94     Require all denied
95   </Directory>
96
97   <Files <%= @directory %>/w/LocalSettings.php>
98     Require all denied
99   </Files>
100
101   <Directory <%= @directory %>/w/cache/>
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 ~ "\.svn">
109     Require all denied
110   </Directory>
111
112   <Directory ~ "\.git">
113     Require all denied
114   </Directory>
115
116   <Files ~ "~$">
117     Require all denied
118   </Files>
119 </VirtualHost>
120 <% end -%>