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