]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/apache.erb
mediawiki: AbuseFilter fix
[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   RewriteCond %{SERVER_NAME} !=<%= @name %>
32 <% if port == 443 -%>
33   RewriteRule ^/(.*)$ https://<%= @name %>/$1 [R=permanent]
34 <% else -%>
35   RewriteRule ^/(.*)$ http://<%= @name %>/$1 [R=permanent]
36 <% end -%>
37
38   RedirectMatch 301 ^/$                           /wiki/Main_Page
39
40   #Historical Compatibility Links
41   RedirectMatch 301 ^/index\.php$                 /w/index.php
42   RedirectMatch 301 ^/index\.php/(.*)$            /wiki/$1
43   RedirectMatch 301 ^/skins/(.*)$                 /w/skins/$1
44   RedirectMatch 301 ^/images/(.*)$                /w/images/$1
45   RedirectMatch 301 ^/api\.php$                   /w/api.php
46   RedirectMatch 301 ^/opensearch_desc\.php$       /w/opensearch_desc.php
47
48   Alias /wiki <%= @directory %>/w/index.php
49
50   #Support /pagename -> /wiki/pagename
51   RewriteEngine on
52   RewriteCond %{REQUEST_URI} !^/w/
53   RewriteCond %{REQUEST_URI} !^/wiki/
54   RewriteCond %{REQUEST_URI} !^/index\.php
55   RewriteCond %{REQUEST_URI} !^/skins/
56   RewriteCond %{REQUEST_URI} !^/images/
57   RewriteCond %{REQUEST_URI} !^/api\.php$
58   RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
59   RewriteCond %{REQUEST_URI} !^/server-status
60   RewriteCond %{LA-U:REQUEST_FILENAME} !-f
61   RewriteCond %{LA-U:REQUEST_FILENAME} !-d
62   RewriteRule ^/(.*) /wiki/$1 [R,L]
63
64   <Directory <%= @directory %>>
65     Options -Indexes
66     Require all granted
67   </Directory>
68
69   <Directory <%= @directory %>/w/images/>
70     # No php execution in the upload area
71     php_admin_flag engine off
72     Options -ExecCGI -Includes -Indexes
73     AllowOverride None
74     AddType text/plain .html .htm .shtml
75 <% if @private -%>
76     Require all denied
77 <% end -%>
78   </Directory>
79
80   <Directory <%= @directory %>/w/images/thumb/>
81     RewriteEngine on
82
83     RewriteCond %{REQUEST_FILENAME} !-f
84     RewriteCond %{REQUEST_FILENAME} !-d
85     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]
86
87     RewriteCond %{REQUEST_FILENAME} !-f
88     RewriteCond %{REQUEST_FILENAME} !-d
89     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]
90
91     RewriteCond %{REQUEST_FILENAME} !-f
92     RewriteCond %{REQUEST_FILENAME} !-d
93     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
94
95     RewriteCond %{REQUEST_FILENAME} !-f
96     RewriteCond %{REQUEST_FILENAME} !-d
97     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]
98   </Directory>
99
100   <Directory <%= @directory %>/w/maintenance/>
101     Require all denied
102   </Directory>
103
104   <Files <%= @directory %>/w/LocalSettings.php>
105     Require all denied
106   </Files>
107
108   <Directory <%= @directory %>/w/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     Require all denied
117   </Directory>
118
119   <Directory ~ "\.git">
120     Require all denied
121   </Directory>
122
123   <Files ~ "~$">
124     Require all denied
125   </Files>
126 </VirtualHost>
127 <% end -%>