]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/apache.erb
586f2391e6ede6d9f5a23408929758b0f95c5794
[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   ProxyFCGISetEnvIf "true" PHP_ADMIN_VALUE "open_basedir=<%= @directory %>/:/usr/share/php/:/dev/null:/tmp/"
36   ProxyFCGISetEnvIf "true" PHP_VALUE "memory_limit=500M\nmax_execution_time=240\nupload_max_filesize=70M\npost_max_size=100M"
37
38   RewriteCond %{SERVER_NAME} !=<%= @name %>
39   RewriteRule ^/(.*)$ https://<%= @name %>/$1 [R=permanent]
40
41   RedirectMatch 301 ^/$                           /wiki/Main_Page
42
43   #Historical Compatibility Links
44   RedirectMatch 301 ^/index\.php$                 /w/index.php
45   RedirectMatch 301 ^/index\.php/(.*)$            /wiki/$1
46   RedirectMatch 301 ^/skins/(.*)$                 /w/skins/$1
47   RedirectMatch 301 ^/images/(.*)$                /w/images/$1
48   RedirectMatch 301 ^/api\.php$                   /w/api.php
49   RedirectMatch 301 ^/opensearch_desc\.php$       /w/opensearch_desc.php
50
51   #Support Wikidata redirects based on Wikimedia's redirects:
52   # https://github.com/wikimedia/puppet/blob/production/modules/mediawiki/files/apache/sites/wikidata-uris.incl
53   RedirectMatch 301 ^/entity/statement/([QqPp]\d+).*$        /wiki/Special:EntityData/$1
54   RedirectMatch 301 ^/value/(.*)$                            /wiki/Special:ListDatatypes
55   RedirectMatch 301 ^/reference/(.*)$                        https://wikidata.org/wiki/Help:Sources
56   RedirectMatch 301 ^/prop/direct/(.*)$                      /wiki/Property:$1
57   RedirectMatch 301 ^/prop/direct-normalized/(.*)$           /wiki/Property:$1
58   RedirectMatch 301 ^/prop/novalue/(.*)$                     /wiki/Property:$1
59   RedirectMatch 301 ^/prop/statement/value/(.*)$             /wiki/Property:$1
60   RedirectMatch 301 ^/prop/statement/value-normalized/(.*)$  /wiki/Property:$1
61   RedirectMatch 301 ^/prop/qualifier/value/(.*)$             /wiki/Property:$1
62   RedirectMatch 301 ^/prop/qualifier/value-normalized/(.*)$  /wiki/Property:$1
63   RedirectMatch 301 ^/prop/reference/value/(.*)$             /wiki/Property:$1
64   RedirectMatch 301 ^/prop/reference/value-normalized/(.*)$  /wiki/Property:$1
65   RedirectMatch 301 ^/prop/statement/(.*)$                   /wiki/Property:$1
66   RedirectMatch 301 ^/prop/qualifier/(.*)$                   /wiki/Property:$1
67   RedirectMatch 301 ^/prop/reference/(.*)$                   /wiki/Property:$1
68   RedirectMatch 301 ^/prop/(.*)$                             /wiki/Property:$1
69   RedirectMatch 301 ^/entity/(.*)$                           /wiki/Special:EntityData/$1
70
71   Alias /wiki <%= @directory %>/w/index.php
72
73   #Support /pagename -> /wiki/pagename
74   RewriteEngine on
75   RewriteCond %{REQUEST_URI} !^/w/
76   RewriteCond %{REQUEST_URI} !^/wiki/
77   RewriteCond %{REQUEST_URI} !^/index\.php
78   RewriteCond %{REQUEST_URI} !^/skins/
79   RewriteCond %{REQUEST_URI} !^/images/
80   RewriteCond %{REQUEST_URI} !^/api\.php$
81   RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
82   RewriteCond %{REQUEST_URI} !^/entity/
83   RewriteCond %{REQUEST_URI} !^/value/
84   RewriteCond %{REQUEST_URI} !^/reference/
85   RewriteCond %{REQUEST_URI} !^/prop/  
86   RewriteCond %{REQUEST_URI} !^/dump/  
87   RewriteCond %{REQUEST_URI} !^/server-status
88   RewriteCond %{REQUEST_URI} !^/.well-known/
89   RewriteCond %{LA-U:REQUEST_FILENAME} !-f
90   RewriteCond %{LA-U:REQUEST_FILENAME} !-d
91   RewriteRule ^/(.*) /wiki/$1 [R,L]
92
93   <Directory <%= @directory %>>
94     Options -Indexes
95     Require all granted
96   </Directory>
97
98   <Directory <%= @directory %>/w/images/>
99     Options -ExecCGI -Includes -Indexes
100     AllowOverride None
101     AddType text/plain .html .htm .shtml
102 <% if @private_site -%>
103     Require all denied
104 <% end -%>
105     <FilesMatch ".+\.ph(ar|p|tml)$">
106       SetHandler None
107     </FilesMatch>
108   </Directory>
109
110   <Directory <%= @directory %>/w/images/thumb/>
111     RewriteEngine on
112
113     RewriteCond %{REQUEST_FILENAME} !-f
114     RewriteCond %{REQUEST_FILENAME} !-d
115     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]
116
117     RewriteCond %{REQUEST_FILENAME} !-f
118     RewriteCond %{REQUEST_FILENAME} !-d
119     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]
120
121     RewriteCond %{REQUEST_FILENAME} !-f
122     RewriteCond %{REQUEST_FILENAME} !-d
123     RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
124
125     RewriteCond %{REQUEST_FILENAME} !-f
126     RewriteCond %{REQUEST_FILENAME} !-d
127     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]
128   </Directory>
129
130   <Directory <%= @directory %>/w/maintenance/>
131     Require all denied
132   </Directory>
133
134   <Files <%= @directory %>/w/LocalSettings.php>
135     Require all denied
136   </Files>
137
138   <Directory <%= @directory %>/w/cache/>
139     Options -ExecCGI -Includes -Indexes
140     AllowOverride None
141     AddType text/plain .html .htm .shtml
142     <FilesMatch ".+\.ph(ar|p|tml)$">
143       SetHandler None
144     </FilesMatch>
145   </Directory>
146
147   <Directory <%= @directory %>/dump/>
148     Options Indexes FollowSymLinks MultiViews
149     AllowOverride All
150     IndexIgnore .ht* . robots.txt HEADER.html HEADER.cgi logo.png style.css
151     IndexOptions FancyIndexing FoldersFirst NameWidth=* TrackModified
152     IndexOrderDefault Descending Date
153   </Directory>
154
155   <Directory ~ "\.svn">
156     Require all denied
157   </Directory>
158
159   <Directory ~ "\.git">
160     Require all denied
161   </Directory>
162
163   <Files ~ "~$">
164     Require all denied
165   </Files>
166 </VirtualHost>