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" 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 CF-Connecting-IP
31 <% @cloudflare.sort.each do |address| -%>
32 RemoteIPTrustedProxy <%= address %>
35 <% @fastly.sort.each do |address| -%>
36 RemoteIPTrustedProxy <%= address %>
40 # Turn on various features
48 RequestReadTimeout handshake=20-40,MinRate=500 header=20-40,MinRate=500 body=20-120,MinRate=500
49 LogLevel reqtimeout:info
52 # Add the unique ID to the request headers
54 RequestHeader set X-Request-Id %{UNIQUE_ID}e
57 # Remove Proxy request header to mitigate https://httpoxy.org/
59 RequestHeader unset Proxy early
62 # Block troublesome GPX data scrapping
64 RewriteCond %{REQUEST_METHOD} HEAD
65 RewriteRule ^/trace/\d+/data - [F,L]
70 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
74 # Block changeset scraper
76 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
82 RewriteCond %{HTTP_USER_AGENT} "python-httpx/0.24.1"
86 # Block out of control spider
88 RewriteCond %{HTTP_USER_AGENT} "Bytespider"
92 # Block attempts to access old API versions
94 RewriteRule ^/api/0.[12345]/ - [G,L]
97 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
98 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
100 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
101 RewriteRule . - [F,L]
104 # Block a changeset that seems to lock things up
106 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
109 # Ignore Vicon Valerus "online" status pings
110 # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
112 RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
113 RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
116 # Ignore GoogleAssociationService request storm
117 # https://en.osm.town/@osm_tech/114205363076771822
119 RewriteCond %{HTTP_USER_AGENT} "GoogleAssociationService"
120 RewriteRule "^/\.well-known/assetlinks\.json$" - [R=429,L]
123 # Force special MIME type for crossdomain.xml files
125 <Files crossdomain.xml>
126 ForceType text/x-cross-domain-policy
130 # Set expiry for assets
133 Header unset Last-Modified
136 ExpiresDefault "access plus 1 year"
137 Header set Cache-Control "immutable, max-age=31536000" "expr=%{REQUEST_STATUS} == 200"
141 # Set expiry for attachments
143 <Location /attachments/>
147 ExpiresDefault "access plus 1 year"
151 # Set expiry for other static content
153 <Location /export/embed.html>
154 ExpiresDefault "access plus 7 days"
157 ExpiresDefault "access plus 10 years"
159 <Location /openlayers/>
160 Header unset Last-Modified
163 Header always set Cache-Control "public, max-age=31536000, immutable"
164 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
170 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
172 PassengerMinInstances 10
173 PassengerMaxRequests 5000
174 PassengerMaxRequestQueueSize 250
175 PassengerPreStart https://www.openstreetmap.org/
176 PassengerAppGroupName rails
177 SetEnv OPENSTREETMAP_STATUS <%= @status %>
178 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
179 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
180 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
181 Alias /funding.json <%= node[:web][:base_directory] %>/static/funding.json
182 Alias /.well-known/funding-manifest-urls <%= node[:web][:base_directory] %>/static/.well-known/funding-manifest-urls
183 Alias /.well-known/security.txt <%= node[:web][:base_directory] %>/static/.well-known/security.txt
184 Alias /security.txt <%= node[:web][:base_directory] %>/static/.well-known/security.txt
185 RedirectPermanent /stats https://planet.openstreetmap.org/statistics
188 # Pass authentication related headers to cgimap
195 # Pass supported calls to cgimap
197 RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
198 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
199 RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
200 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
201 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
202 RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
203 RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
204 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
205 RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
206 RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
209 # Redirect trac and wiki requests to the right places
211 RedirectPermanent /trac/ https://trac.openstreetmap.org/
212 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
215 # Redirect requests for various images to the right place
217 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
218 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
221 # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
223 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
224 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
227 # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
229 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
230 RewriteCond %{REQUEST_URI} !^/api/
231 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
235 ServerName openstreetmap.org.uk
236 ServerAlias www.openstreetmap.org.uk
237 ServerAlias openstreetmap.co.uk
238 ServerAlias www.openstreetmap.co.uk
240 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
241 RedirectPermanent / https://www.openstreetmap.org/
247 Header always set Cache-Control "max-age=31536000"
248 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
252 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
254 RewriteCond %{REQUEST_URI} !^/server-status$
255 RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
259 ServerName www.osm.org
261 Header always set Cache-Control "max-age=31536000"
262 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
266 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
268 RewriteCond %{REQUEST_URI} !^/server-status$
269 RewriteRule ^(.*)$ https://www.osm.org$1 [L,NE,R=permanent]
273 ServerName openstreetmap.org
275 Header always set Cache-Control "max-age=31536000"
276 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
280 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
282 RewriteCond %{REQUEST_URI} !^/server-status$
283 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
287 ServerName www.openstreetmap.org
290 Header always set Cache-Control "max-age=31536000"
291 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
295 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
297 RewriteCond %{REQUEST_URI} !^/server-status$
298 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
302 ServerName openstreetmap.org
306 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
307 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
309 Header always set Cache-Control "max-age=31536000"
310 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
312 RedirectPermanent / https://www.openstreetmap.org/
315 <Directory <%= node[:web][:base_directory] %>/rails/public>
318 RewriteCond "%{HTTP:Accept-encoding}" "br"
319 RewriteCond "%{REQUEST_FILENAME}\.br" -s
320 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
322 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
323 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
324 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
326 RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
327 RewriteRule "\.ico\.(br|gz)$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
328 RewriteRule "\.js\.(br|gz)$" "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
329 RewriteRule "\.json\.(br|gz)$" "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
330 RewriteRule "\.svg\.(br|gz)$" "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
331 RewriteRule "\.xml\.(br|gz)$" "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
333 <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
334 Header append Content-Encoding br
335 Header append Vary Accept-Encoding
338 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
339 Header append Content-Encoding gzip
340 Header append Vary Accept-Encoding
344 <Directory /srv/www.openstreetmap.org/static>
347 <Files "funding-manifest-urls">
352 <Directory /srv/www.openstreetmap.org/rails/app/assets>
356 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>