1 # DO NOT EDIT - This file is being maintained by Chef
5 # Basic server configuration
7 ServerName <%= node[:fqdn] %>
8 ServerAlias api.openstreetmap.org www.openstreetmap.org 127.0.0.1
9 ServerAdmin webmaster@openstreetmap.org
15 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
16 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
21 SetEnvIfNoCase Authorization "^Basic " AUTH_METHOD=basic
22 SetEnvIfNoCase Authorization "^OAuth " AUTH_METHOD=oauth1
23 SetEnvIfNoCase Authorization "^Bearer " AUTH_METHOD=oauth2
24 SetEnvIfExpr "%{QUERY_STRING} =~ /(^|&)oauth_signature=/" AUTH_METHOD=oauth1
25 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
26 CustomLog /var/log/apache2/access.log combined_with_time
27 ErrorLog /var/log/apache2/error.log
30 # Turn on various features
38 RequestReadTimeout handshake=20-40,MinRate=500 header=20-40,MinRate=500 body=20,MinRate=500
41 # Add the unique ID to the request headers
43 RequestHeader set X-Request-Id %{UNIQUE_ID}e
46 # Remove Proxy request header to mitigate https://httpoxy.org/
48 RequestHeader unset Proxy early
51 # Block troublesome GPX data scrapping
53 RewriteCond %{REQUEST_METHOD} HEAD
54 RewriteRule ^/trace/\d+/data - [F,L]
59 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
63 # Block changeset scraper
65 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
71 RewriteCond %{HTTP_USER_AGENT} "python-httpx/0.24.1"
75 # Block out of control spider
77 RewriteCond %{HTTP_USER_AGENT} "Bytespider"
81 # Block attempts to access old API versions
83 RewriteRule ^/api/0.[12345]/ - [G,L]
86 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
87 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
89 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
93 # Block a changeset that seems to lock things up
95 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
98 # Ignore Vicon Valerus "online" status pings
99 # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
101 RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
102 RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
105 # Force special MIME type for crossdomain.xml files
107 <Files crossdomain.xml>
108 ForceType text/x-cross-domain-policy
112 # Set expiry for assets
115 Header unset Last-Modified
118 ExpiresDefault "access plus 1 year"
119 Header set Cache-Control "immutable, max-age=31536000"
123 # Set expiry for attachments
125 <Location /attachments/>
129 ExpiresDefault "access plus 1 year"
133 # Set expiry for other static content
135 <Location /export/embed.html>
136 ExpiresDefault "access plus 7 days"
139 ExpiresDefault "access plus 10 years"
141 <Location /openlayers/>
142 Header unset Last-Modified
145 Header always set Cache-Control "public, max-age=31536000, immutable"
146 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
152 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
154 PassengerMinInstances 10
155 PassengerMaxRequests 5000
156 PassengerMaxRequestQueueSize 250
157 PassengerPreStart https://www.openstreetmap.org/
158 PassengerAppGroupName rails
159 SetEnv OPENSTREETMAP_STATUS <%= @status %>
160 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
161 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
162 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
163 RedirectPermanent /stats https://planet.openstreetmap.org/statistics
166 # Pass authentication related headers to cgimap
173 # Pass supported calls to cgimap
175 RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
176 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
177 RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
178 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
179 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
180 RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
181 RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
182 RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
183 RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
186 # Redirect trac and wiki requests to the right places
188 RedirectPermanent /trac/ https://trac.openstreetmap.org/
189 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
192 # Redirect requests for various images to the right place
194 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
195 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
198 # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
200 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
201 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
204 # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
206 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
207 RewriteCond %{REQUEST_URI} !^/api/
208 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
212 ServerName openstreetmap.org.uk
213 ServerAlias www.openstreetmap.org.uk
214 ServerAlias openstreetmap.co.uk
215 ServerAlias www.openstreetmap.co.uk
217 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
218 RedirectPermanent / https://www.openstreetmap.org/
224 Header always set Cache-Control "max-age=31536000"
225 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
229 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
231 RewriteCond %{REQUEST_URI} !^/server-status$
232 RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
236 ServerName www.osm.org
238 Header always set Cache-Control "max-age=31536000"
239 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
243 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
245 RewriteCond %{REQUEST_URI} !^/server-status$
246 RewriteRule ^(.*)$ https://www.osm.org$1 [L,NE,R=permanent]
250 ServerName openstreetmap.org
252 Header always set Cache-Control "max-age=31536000"
253 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
257 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
259 RewriteCond %{REQUEST_URI} !^/server-status$
260 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
264 ServerName www.openstreetmap.org
267 Header always set Cache-Control "max-age=31536000"
268 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
272 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
274 RewriteCond %{REQUEST_URI} !^/server-status$
275 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
279 ServerName openstreetmap.org
283 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
284 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
286 Header always set Cache-Control "max-age=31536000"
287 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
289 RedirectPermanent / https://www.openstreetmap.org/
292 <Directory <%= node[:web][:base_directory] %>/rails/public>
295 RewriteCond "%{HTTP:Accept-encoding}" "br"
296 RewriteCond "%{REQUEST_FILENAME}\.br" -s
297 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
299 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
300 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
301 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
303 RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
304 RewriteRule "\.ico\.(br|gz)$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
305 RewriteRule "\.js\.(br|gz)$" "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
306 RewriteRule "\.json\.(br|gz)$" "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
307 RewriteRule "\.svg\.(br|gz)$" "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
308 RewriteRule "\.xml\.(br|gz)$" "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
310 <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
311 Header append Content-Encoding br
312 Header append Vary Accept-Encoding
315 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
316 Header append Content-Encoding gzip
317 Header append Vary Accept-Encoding
321 <Directory /srv/www.openstreetmap.org/static>
325 <Directory /srv/www.openstreetmap.org/rails/app/assets>
329 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>