1 # DO NOT EDIT - This file is being maintained by Chef
6 SetEnvIfNoCase Authorization "^Basic " AUTH_METHOD=basic
7 SetEnvIfNoCase Authorization "^OAuth " AUTH_METHOD=oauth1
8 SetEnvIfNoCase Authorization "^Bearer " AUTH_METHOD=oauth2
9 SetEnvIfExpr "%{QUERY_STRING} =~ /(^|&)oauth_signature=/" AUTH_METHOD=oauth1
10 LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Dus %{UNIQUE_ID}e %{SSL_PROTOCOL}x %{SSL_CIPHER}x %{AUTH_METHOD}e \"%{X-TLS-JA4}i\" \"%{X-JA4H}i\"" combined_with_time
11 CustomLog /var/log/apache2/access.log combined_with_time
12 ErrorLog /var/log/apache2/error.log
16 # Basic server configuration
18 ServerName <%= node[:fqdn] %>
19 ServerAlias api.openstreetmap.org www.openstreetmap.org 127.0.0.1
20 ServerAdmin webmaster@openstreetmap.org
26 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
27 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
29 # Get the real remote IP for requests via a trusted proxy
30 RemoteIPHeader Fastly-Client-IP
32 <% @fastly.sort.each do |address| -%>
33 RemoteIPTrustedProxy <%= address %>
37 # Turn on various features
45 RequestReadTimeout handshake=20-40,MinRate=500 header=20-40,MinRate=500 body=20-120,MinRate=500
46 LogLevel reqtimeout:info
49 # Add the unique ID to the request headers
51 RequestHeader set X-Request-Id %{UNIQUE_ID}e
54 # Remove Proxy request header to mitigate https://httpoxy.org/
56 RequestHeader unset Proxy early
59 # Block troublesome GPX data scrapping
61 RewriteCond %{REQUEST_METHOD} HEAD
62 RewriteRule ^/trace/\d+/data - [F,L]
67 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
71 # Block changeset scraper
73 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
79 RewriteCond %{HTTP_USER_AGENT} "python-httpx/0.24.1"
83 # Block out of control spider
85 RewriteCond %{HTTP_USER_AGENT} "Bytespider"
89 # Block attempts to access old API versions
91 RewriteRule ^/api/0.[12345]/ - [G,L]
94 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
95 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
97 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
101 # Block a changeset that seems to lock things up
103 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
106 # Ignore Vicon Valerus "online" status pings
107 # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
109 RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
110 RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
113 # Ignore GoogleAssociationService request storm
114 # https://en.osm.town/@osm_tech/114205363076771822
116 RewriteCond %{HTTP_USER_AGENT} "GoogleAssociationService"
117 RewriteRule "^/\.well-known/assetlinks\.json$" - [R=429,L]
120 # Drop faulty Cloudflare POST /cdn-cgi/rum submissions reaching us
122 RewriteCond %{REQUEST_METHOD} =POST
123 RewriteRule ^/cdn-cgi/rum$ - [F,L]
126 # Block bogus referers
128 RewriteCond %{HTTP_REFERER} "^https://<%= Regexp.escape(node[:fqdn]) %>/"
129 RewriteRule . - [F,L]
132 # Block bogus user agents
134 # removed 2026-03-08, doesn't work with Fastly turning everything to http 1.1
135 # RewriteCond %{SERVER_PROTOCOL} =HTTP/1.1
136 # RewriteCond %{HTTP_USER_AGENT} Chrome/((103|105|107|108|109|110|111|112|116|117|120|124|131|133)\.0\.0\.0|104\.0\.5112\.81|106\.0\.5249\.119) [NC]
137 # RewriteRule . - [F,L]
140 # Redirect ACME certificate challenges (Fastly redirects from HTTP to HTTPS, so we need to handle them here)
142 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
145 # Force special MIME type for crossdomain.xml files
147 <Files crossdomain.xml>
148 ForceType text/x-cross-domain-policy
152 # Set expiry for assets
155 Header unset Last-Modified
158 ExpiresDefault "access plus 1 year"
159 Header set Cache-Control "immutable, max-age=31536000" "expr=%{REQUEST_STATUS} == 200"
163 # Set expiry for attachments
165 <Location /attachments/>
169 ExpiresDefault "access plus 1 year"
173 # Set expiry for other static content
175 <Location /export/embed.html>
176 ExpiresDefault "access plus 7 days"
177 Header always set Referrer-Policy "no-referrer-when-downgrade"
180 ExpiresDefault "access plus 10 years"
182 <Location /openlayers/>
183 Header unset Last-Modified
186 Header always set Cache-Control "public, max-age=31536000, immutable"
187 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
193 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
195 PassengerMinInstances 10
196 PassengerMaxRequests 5000
197 PassengerMaxRequestQueueSize 250
198 PassengerPreStart https://www.openstreetmap.org/
199 PassengerAppGroupName rails
200 SetEnv OPENSTREETMAP_STATUS <%= @status %>
201 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
202 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
203 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
204 Alias /funding.json <%= node[:web][:base_directory] %>/static/funding.json
205 Alias /.well-known/funding-manifest-urls <%= node[:web][:base_directory] %>/static/.well-known/funding-manifest-urls
206 Alias /.well-known/security.txt <%= node[:web][:base_directory] %>/static/.well-known/security.txt
207 Alias /security.txt <%= node[:web][:base_directory] %>/static/.well-known/security.txt
208 RedirectPermanent /stats https://planet.openstreetmap.org/statistics
211 # Pass authentication related headers to cgimap
218 # Normalise Accept-Encoding headers to workaround cgimap bug
220 RequestHeader edit* Accept-Encoding "\\s*,\\s*" ", "
223 # Disable deflate for applications that claim to handle it but can't
225 SetEnvIfNoCase User-Agent "StreetComplete" broken_deflate_client
226 SetEnvIfNoCase Referer "app:/resources/potlatch2.swf" broken_deflate_client
227 RequestHeader edit Accept-Encoding "deflate" "unsupported" env=broken_deflate_client
230 # Pass supported calls to cgimap
232 RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
233 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
234 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
235 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
236 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
237 RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
238 RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
239 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
240 RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
241 RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
244 # Redirect trac and wiki requests to the right places
246 RedirectPermanent /trac/ https://trac.openstreetmap.org/
247 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
250 # Redirect requests for various images to the right place
252 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
253 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
256 # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
258 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
259 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
262 # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
264 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
265 RewriteCond %{REQUEST_URI} !^/api/
266 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
268 # Restrict access to CDN nodes and admins
270 Require expr "%{CONN_REMOTE_ADDR} != %{REMOTE_ADDR}"
272 <% @fastly.sort.each do |address| -%>
273 Require ip <%= address %>
275 # StatusCake monitoring
276 <% @statuscake.sort.reject { |address| address.empty? }.each do |address| -%>
277 Require ip <%= address %>
280 <% @admins.sort.each do |address| -%>
281 Require ip <%= address %>
283 # OSM Amsterdam IPv4 (he.net)
284 Require ip 184.104.179.128/27
285 # OSM Amsterdam IPv4 (equinix)
286 Require ip 82.199.86.96/27
287 # OSM Amsterdam IPv6 (he.net)
288 Require ip 2001:470:1:fa1::/64
289 # OSM Amsterdam IPv6 (equinix)
290 Require ip 2001:4d78:500:5e3::/64
291 # OSM Dublin IPv4 (he.net)
292 Require ip 184.104.226.96/27
293 # OSM Dublin IPv4 (equinix)
294 Require ip 87.252.214.96/27
295 # OSM Dublin IPv6 (he.net)
296 Require ip 2001:470:1:b3b::/64
297 # OSM Dublin IPv6 (equinix)
298 Require ip 2001:4d78:fe03:1c::/64
300 Require ip 193.60.236.0/24
305 ServerName openstreetmap.org.uk
306 ServerAlias www.openstreetmap.org.uk
307 ServerAlias openstreetmap.co.uk
308 ServerAlias www.openstreetmap.co.uk
310 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
311 RedirectPermanent / https://www.openstreetmap.org/
317 Header always set Cache-Control "max-age=31536000"
318 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
322 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
324 RewriteCond %{REQUEST_URI} !^/server-status$
325 RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
329 ServerName www.osm.org
331 Header always set Cache-Control "max-age=31536000"
332 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
336 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
338 RewriteCond %{REQUEST_URI} !^/server-status$
339 RewriteRule ^(.*)$ https://www.osm.org$1 [L,NE,R=permanent]
343 ServerName openstreetmap.org
345 Header always set Cache-Control "max-age=31536000"
346 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
350 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
352 RewriteCond %{REQUEST_URI} !^/server-status$
353 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
357 ServerName www.openstreetmap.org
360 Header always set Cache-Control "max-age=31536000"
361 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
365 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
367 RewriteCond %{REQUEST_URI} !^/server-status$
368 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
372 ServerName openstreetmap.org
376 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
377 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
379 Header always set Cache-Control "max-age=31536000"
380 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
382 RedirectPermanent / https://www.openstreetmap.org/
385 <Directory <%= node[:web][:base_directory] %>/rails/public>
388 RewriteCond "%{HTTP:Accept-encoding}" "br"
389 RewriteCond "%{REQUEST_FILENAME}\.br" -s
390 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
392 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
393 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
394 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
396 RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
397 RewriteRule "\.ico\.(br|gz)$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
398 RewriteRule "\.js\.(br|gz)$" "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
399 RewriteRule "\.json\.(br|gz)$" "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
400 RewriteRule "\.svg\.(br|gz)$" "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
401 RewriteRule "\.xml\.(br|gz)$" "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
403 <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
404 Header append Content-Encoding br
405 Header append Vary Accept-Encoding
408 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
409 Header append Content-Encoding gzip
410 Header append Vary Accept-Encoding
414 <Directory /srv/www.openstreetmap.org/static>
417 <Files "funding-manifest-urls">
422 <Directory /srv/www.openstreetmap.org/rails/app/assets>
426 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>