]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/apache.erb
7aba9752b87d91e5850f0b19b4e0491814b66ed6
[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   RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
15   RedirectPermanent / https://<%= @name %>/
16 </VirtualHost>
17
18 <VirtualHost *:443>
19   ServerName <%= @name %>
20 <% @aliases.each do |alias_name| -%>
21   ServerAlias <%= alias_name %>
22 <% end -%>
23
24   ServerAdmin webmaster@openstreetmap.org
25
26   SSLEngine on
27   SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
28   SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
29
30   CustomLog /var/log/apache2/<%= @name %>-secure-access.log combined
31   ErrorLog /var/log/apache2/<%= @name %>-secure-error.log
32
33   DocumentRoot <%= @directory %>
34
35   php_admin_value open_basedir <%= @directory %>/:/usr/share/php/:/dev/null:/tmp/
36   #php_admin_value disable_functions "exec,shell_exec,system,passthru,popen,proc_open"
37   php_value memory_limit 500M
38   php_value max_execution_time 240
39   php_value upload_max_filesize 70M
40   php_value post_max_size 100M
41
42   RewriteCond %{SERVER_NAME} !=<%= @name %>
43   RewriteRule ^/(.*)$ https://<%= @name %>/$1 [R=permanent]
44
45   RedirectMatch 301 ^/$                           /wiki/Main_Page
46
47   #Historical Compatibility Links
48   RedirectMatch 301 ^/index\.php$                 /w/index.php
49   RedirectMatch 301 ^/index\.php/(.*)$            /wiki/$1
50   RedirectMatch 301 ^/skins/(.*)$                 /w/skins/$1
51   RedirectMatch 301 ^/images/(.*)$                /w/images/$1
52   RedirectMatch 301 ^/api\.php$                   /w/api.php
53   RedirectMatch 301 ^/opensearch_desc\.php$       /w/opensearch_desc.php
54
55   #Support Wikidata redirects based on Wikimedia's redirects:
56   # https://github.com/wikimedia/puppet/blob/production/modules/mediawiki/files/apache/sites/wikidata-uris.incl
57   RedirectMatch 301 ^/entity/statement/([QqPp]\d+).*$        /wiki/Special:EntityData/$1
58   RedirectMatch 301 ^/value/(.*)$                            /wiki/Special:ListDatatypes
59   RedirectMatch 301 ^/reference/(.*)$                        https://wikidata.org/wiki/Help:Sources
60   RedirectMatch 301 ^/prop/direct/(.*)$                      /wiki/Property:$1
61   RedirectMatch 301 ^/prop/direct-normalized/(.*)$           /wiki/Property:$1
62   RedirectMatch 301 ^/prop/novalue/(.*)$                     /wiki/Property:$1
63   RedirectMatch 301 ^/prop/statement/value/(.*)$             /wiki/Property:$1
64   RedirectMatch 301 ^/prop/statement/value-normalized/(.*)$  /wiki/Property:$1
65   RedirectMatch 301 ^/prop/qualifier/value/(.*)$             /wiki/Property:$1
66   RedirectMatch 301 ^/prop/qualifier/value-normalized/(.*)$  /wiki/Property:$1
67   RedirectMatch 301 ^/prop/reference/value/(.*)$             /wiki/Property:$1
68   RedirectMatch 301 ^/prop/reference/value-normalized/(.*)$  /wiki/Property:$1
69   RedirectMatch 301 ^/prop/statement/(.*)$                   /wiki/Property:$1
70   RedirectMatch 301 ^/prop/qualifier/(.*)$                   /wiki/Property:$1
71   RedirectMatch 301 ^/prop/reference/(.*)$                   /wiki/Property:$1
72   RedirectMatch 301 ^/prop/(.*)$                             /wiki/Property:$1
73   RedirectMatch 301 ^/entity/(.*)$                           /wiki/Special:EntityData/$1
74
75   Alias /wiki <%= @directory %>/w/index.php
76
77   #Support /pagename -> /wiki/pagename
78   RewriteEngine on
79   RewriteCond %{REQUEST_URI} !^/w/
80   RewriteCond %{REQUEST_URI} !^/wiki/
81   RewriteCond %{REQUEST_URI} !^/index\.php
82   RewriteCond %{REQUEST_URI} !^/skins/
83   RewriteCond %{REQUEST_URI} !^/images/
84   RewriteCond %{REQUEST_URI} !^/api\.php$
85   RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
86   RewriteCond %{REQUEST_URI} !^/entity/
87   RewriteCond %{REQUEST_URI} !^/value/
88   RewriteCond %{REQUEST_URI} !^/reference/
89   RewriteCond %{REQUEST_URI} !^/prop/  
90   RewriteCond %{REQUEST_URI} !^/server-status
91   RewriteCond %{REQUEST_URI} !^/.well-known/
92   RewriteCond %{LA-U:REQUEST_FILENAME} !-f
93   RewriteCond %{LA-U:REQUEST_FILENAME} !-d
94   RewriteRule ^/(.*) /wiki/$1 [R,L]
95
96   <Directory <%= @directory %>>
97     Options -Indexes
98     Require all granted
99   </Directory>
100
101   <Directory <%= @directory %>/w/images/>
102     # No php execution in the upload area
103     php_admin_flag engine off
104     Options -ExecCGI -Includes -Indexes
105     AllowOverride None
106     AddType text/plain .html .htm .shtml
107 <% if @private_site -%>
108     Require all denied
109 <% end -%>
110   </Directory>
111
112   <Directory <%= @directory %>/w/images/thumb/>
113     RewriteEngine on
114
115     RewriteCond %{REQUEST_FILENAME} !-f
116     RewriteCond %{REQUEST_FILENAME} !-d
117     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]
118
119     RewriteCond %{REQUEST_FILENAME} !-f
120     RewriteCond %{REQUEST_FILENAME} !-d
121     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]
122
123     RewriteCond %{REQUEST_FILENAME} !-f
124     RewriteCond %{REQUEST_FILENAME} !-d
125     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
126
127     RewriteCond %{REQUEST_FILENAME} !-f
128     RewriteCond %{REQUEST_FILENAME} !-d
129     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]
130   </Directory>
131
132   <Directory <%= @directory %>/w/maintenance/>
133     Require all denied
134   </Directory>
135
136   <Files <%= @directory %>/w/LocalSettings.php>
137     Require all denied
138   </Files>
139
140   <Directory <%= @directory %>/w/cache/>
141     Options -ExecCGI -Includes -Indexes
142     AllowOverride None
143     AddType text/plain .html .htm .shtml
144     php_admin_flag engine off
145   </Directory>
146
147   <Directory ~ "\.svn">
148     Require all denied
149   </Directory>
150
151   <Directory ~ "\.git">
152     Require all denied
153   </Directory>
154
155   <Files ~ "~$">
156     Require all denied
157   </Files>
158 </VirtualHost>