1 # DO NOT EDIT - This file is being maintained by Chef
4 ServerName <%= @name %>
5 <% @aliases.each do |alias_name| -%>
6 ServerAlias <%= alias_name %>
9 ServerAdmin webmaster@openstreetmap.org
11 CustomLog /var/log/apache2/<%= @name %>-access.log combined_extended
12 ErrorLog /var/log/apache2/<%= @name %>-error.log
14 RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
15 RedirectPermanent / https://<%= @name %>/
19 ServerName <%= @name %>
20 <% @aliases.each do |alias_name| -%>
21 ServerAlias <%= alias_name %>
24 ServerAdmin webmaster@openstreetmap.org
27 SSLCertificateFile /etc/ssl/certs/<%= @name %>.pem
28 SSLCertificateKeyFile /etc/ssl/private/<%= @name %>.key
30 CustomLog /var/log/apache2/<%= @name %>-access.log combined_extended
31 ErrorLog /var/log/apache2/<%= @name %>-error.log
33 DocumentRoot <%= @directory %>
35 AllowEncodedSlashes NoDecode
39 RewriteCond %{SERVER_NAME} !=<%= @name %>
40 RewriteRule ^/(.*)$ https://<%= @name %>/$1 [R=permanent]
42 # Prevent abuse by an anonymous AI bot
43 RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
44 RewriteCond %{REQUEST_URI} ^/w/index\.php$ [OR]
45 RewriteCond %{REQUEST_URI} ^/wiki/Special: [OR]
46 RewriteCond %{REQUEST_URI} ^/w/api\.php$
47 RewriteCond %{HTTP_REFERER} ^-?$
48 RewriteCond %{HTTP_USER_AGENT} ((CriOS|Chrome)/[1-9][0-9]?\.0\.|Chrome/100\.0\.|Chrome/122\.0\.0\.0|(Firefox|FxiOS)/[1-6]?[0-9]\.|MSIE\ [5-9]\.0|Opera/[8-9]\.|Windows\ NT\ [3-5]\.|Version/[3-5]\.[0-1]) [NC]
49 RewriteRule ^ - [R=429,L]
51 # Historical Compatibility Links
52 RedirectMatch 301 ^/index\.php$ /w/index.php
53 RedirectMatch 301 ^/index\.php/(.*)$ /wiki/$1
54 RedirectMatch 301 ^/skins/(.*)$ /w/skins/$1
55 RedirectMatch 301 ^/images/(.*)$ /w/images/$1
56 RedirectMatch 301 ^/api\.php$ /w/api.php
57 RedirectMatch 301 ^/opensearch_desc\.php$ /w/opensearch_desc.php
59 # Support Wikidata redirects based on Wikimedia's redirects:
60 # https://github.com/wikimedia/puppet/blob/production/modules/mediawiki/files/apache/sites/wikidata-uris.incl
61 RedirectMatch 301 ^/entity/statement/([QqPp]\d+).*$ /wiki/Special:EntityData/$1
62 RedirectMatch 301 ^/value/(.*)$ /wiki/Special:ListDatatypes
63 RedirectMatch 301 ^/reference/(.*)$ https://wikidata.org/wiki/Help:Sources
64 RedirectMatch 301 ^/prop/direct/(.*)$ /wiki/Property:$1
65 RedirectMatch 301 ^/prop/direct-normalized/(.*)$ /wiki/Property:$1
66 RedirectMatch 301 ^/prop/novalue/(.*)$ /wiki/Property:$1
67 RedirectMatch 301 ^/prop/statement/value/(.*)$ /wiki/Property:$1
68 RedirectMatch 301 ^/prop/statement/value-normalized/(.*)$ /wiki/Property:$1
69 RedirectMatch 301 ^/prop/qualifier/value/(.*)$ /wiki/Property:$1
70 RedirectMatch 301 ^/prop/qualifier/value-normalized/(.*)$ /wiki/Property:$1
71 RedirectMatch 301 ^/prop/reference/value/(.*)$ /wiki/Property:$1
72 RedirectMatch 301 ^/prop/reference/value-normalized/(.*)$ /wiki/Property:$1
73 RedirectMatch 301 ^/prop/statement/(.*)$ /wiki/Property:$1
74 RedirectMatch 301 ^/prop/qualifier/(.*)$ /wiki/Property:$1
75 RedirectMatch 301 ^/prop/reference/(.*)$ /wiki/Property:$1
76 RedirectMatch 301 ^/prop/(.*)$ /wiki/Property:$1
77 RedirectMatch 301 ^/entity/(.*)$ /wiki/Special:EntityData/$1
79 Alias /wiki <%= @directory %>/w/index.php
81 # Support /pagename -> /wiki/pagename
83 RewriteRule ^/$ /w/index.php?title=Main_Page [L,QSA]
84 RewriteCond %{REQUEST_URI} !^/w/
85 RewriteCond %{REQUEST_URI} !^/wiki/
86 RewriteCond %{REQUEST_URI} !^/index\.php
87 RewriteCond %{REQUEST_URI} !^/skins/
88 RewriteCond %{REQUEST_URI} !^/images/
89 RewriteCond %{REQUEST_URI} !^/api\.php$
90 RewriteCond %{REQUEST_URI} !^/opensearch_desc\.php$
91 RewriteCond %{REQUEST_URI} !^/entity/
92 RewriteCond %{REQUEST_URI} !^/value/
93 RewriteCond %{REQUEST_URI} !^/reference/
94 RewriteCond %{REQUEST_URI} !^/prop/
95 RewriteCond %{REQUEST_URI} !^/dump/
96 RewriteCond %{REQUEST_URI} !^/server-status
97 RewriteCond %{REQUEST_URI} !^/server-info
98 RewriteCond %{REQUEST_URI} !^/.well-known/
99 RewriteCond %{LA-U:REQUEST_FILENAME} !-f
100 RewriteCond %{LA-U:REQUEST_FILENAME} !-d
101 RewriteRule ^/(.*) /wiki/$1 [R,L]
103 <Directory <%= @directory %>>
107 <FilesMatch ".+\.ph(ar|p|tml)$">
108 SetHandler "proxy:unix:/run/php/php-<%= @name %>-fpm.sock|fcgi://127.0.0.1"
112 <Directory <%= @directory %>/w/images/>
113 Options -ExecCGI -Includes -Indexes
115 AddType text/plain .html .htm .shtml
116 <% if @private_site -%>
119 <FilesMatch ".+\.ph(ar|p|tml)$">
124 <Directory <%= @directory %>/w/images/thumb/>
127 RewriteCond %{REQUEST_FILENAME} !-f
128 RewriteCond %{REQUEST_FILENAME} !-d
129 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]
131 RewriteCond %{REQUEST_FILENAME} !-f
132 RewriteCond %{REQUEST_FILENAME} !-d
133 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]
135 RewriteCond %{REQUEST_FILENAME} !-f
136 RewriteCond %{REQUEST_FILENAME} !-d
137 RewriteRule ^[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /w/thumb.php?f=$1&width=$2 [L,QSA,B]
139 RewriteCond %{REQUEST_FILENAME} !-f
140 RewriteCond %{REQUEST_FILENAME} !-d
141 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]
144 <Directory <%= @directory %>/w/maintenance/>
148 <Files <%= @directory %>/w/LocalSettings.php>
152 <Directory <%= @directory %>/w/cache/>
153 Options -ExecCGI -Includes -Indexes
155 AddType text/plain .html .htm .shtml
156 <FilesMatch ".+\.ph(ar|p|tml)$">
161 <Directory <%= @directory %>/dump/>
162 Options Indexes FollowSymLinks MultiViews
164 IndexIgnore .ht* . robots.txt HEADER.html HEADER.cgi logo.png style.css
165 IndexOptions FancyIndexing FoldersFirst NameWidth=* TrackModified
166 IndexOrderDefault Descending Date
169 <Directory ~ "\.svn">
173 <Directory ~ "\.git">