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 SetEnvIfExpr "%{QUERY_STRING} =~ /(^|&)oauth_signature=/" AUTH_METHOD=oauth1
24 SetEnvIfNoCase Authorization "^Bearer " AUTH_METHOD=oauth2
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"
69 # Block attempts to access old API versions
71 RewriteRule ^/api/0.[12345]/ - [G,L]
74 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
75 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
77 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
81 # Block a changeset that seems to lock things up
83 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
86 # Ignore Vicon Valerus "online" status pings
87 # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
89 RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
90 RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
93 # Force special MIME type for crossdomain.xml files
95 <Files crossdomain.xml>
96 ForceType text/x-cross-domain-policy
100 # Set expiry for assets
103 Header unset Last-Modified
106 ExpiresDefault "access plus 1 year"
107 Header set Cache-Control "immutable, max-age=31536000"
111 # Set expiry for attachments
113 <Location /attachments/>
117 ExpiresDefault "access plus 1 year"
121 # Set expiry for other static content
123 <Location /export/embed.html>
124 ExpiresDefault "access plus 7 days"
127 ExpiresDefault "access plus 10 years"
129 <Location /openlayers/>
130 Header unset Last-Modified
133 Header always set Cache-Control "public, max-age=31536000, immutable"
134 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
140 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
142 PassengerMinInstances 10
143 PassengerMaxRequests 5000
144 PassengerMaxRequestQueueSize 250
145 PassengerPreStart https://www.openstreetmap.org/
146 PassengerAppGroupName rails
147 SetEnv OPENSTREETMAP_STATUS <%= @status %>
148 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
149 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
150 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
151 RedirectPermanent /stats https://planet.openstreetmap.org/statistics
154 # Pass authentication related headers to cgimap
161 # Pass supported calls to cgimap
163 RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
164 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
165 RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
166 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
167 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
168 RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
169 RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
170 RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
171 RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
174 # Redirect trac and wiki requests to the right places
176 RedirectPermanent /trac/ https://trac.openstreetmap.org/
177 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
180 # Redirect requests for various images to the right place
182 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
183 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
186 # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
188 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
189 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
192 # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
194 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
195 RewriteCond %{REQUEST_URI} !^/api/
196 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
200 ServerName openstreetmap.org.uk
201 ServerAlias www.openstreetmap.org.uk
202 ServerAlias openstreetmap.co.uk
203 ServerAlias www.openstreetmap.co.uk
205 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
206 RedirectPermanent / https://www.openstreetmap.org/
212 Header always set Cache-Control "max-age=31536000"
213 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
217 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
219 RewriteCond %{REQUEST_URI} !^/server-status$
220 RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
224 ServerName www.osm.org
226 Header always set Cache-Control "max-age=31536000"
227 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
231 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
233 RewriteCond %{REQUEST_URI} !^/server-status$
234 RewriteRule ^(.*)$ https://www.osm.org$1 [L,NE,R=permanent]
238 ServerName openstreetmap.org
240 Header always set Cache-Control "max-age=31536000"
241 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
245 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
247 RewriteCond %{REQUEST_URI} !^/server-status$
248 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
252 ServerName www.openstreetmap.org
255 Header always set Cache-Control "max-age=31536000"
256 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
260 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
262 RewriteCond %{REQUEST_URI} !^/server-status$
263 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
267 ServerName openstreetmap.org
271 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
272 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
274 Header always set Cache-Control "max-age=31536000"
275 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
277 RedirectPermanent / https://www.openstreetmap.org/
280 <Directory <%= node[:web][:base_directory] %>/rails/public>
283 RewriteCond "%{HTTP:Accept-encoding}" "br"
284 RewriteCond "%{REQUEST_FILENAME}\.br" -s
285 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
287 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
288 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
289 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
291 RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
292 RewriteRule "\.ico\.(br|gz)$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
293 RewriteRule "\.js\.(br|gz)$" "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
294 RewriteRule "\.json\.(br|gz)$" "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
295 RewriteRule "\.svg\.(br|gz)$" "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
296 RewriteRule "\.xml\.(br|gz)$" "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
298 <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
299 Header append Content-Encoding br
300 Header append Vary Accept-Encoding
303 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
304 Header append Content-Encoding gzip
305 Header append Vary Accept-Encoding
309 <Directory /srv/www.openstreetmap.org/static>
313 <Directory /srv/www.openstreetmap.org/rails/app/assets>
317 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>