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 LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Dus %{UNIQUE_ID}e %{SSL_PROTOCOL}x %{SSL_CIPHER}x" combined_with_time
22 CustomLog /var/log/apache2/access.log combined_with_time
23 CustomLog /var/log/apache2/basic.log combined_with_time "expr=%{HTTP:Authorization} =~ /^Basic/i"
24 ErrorLog /var/log/apache2/error.log
27 # Turn on various features
35 RequestReadTimeout handshake=20-40,MinRate=500 header=20-40,MinRate=500 body=20,MinRate=500
38 # Add the unique ID to the request headers
40 RequestHeader set X-Request-Id %{UNIQUE_ID}e
43 # Remove Proxy request header to mitigate https://httpoxy.org/
45 RequestHeader unset Proxy early
48 # Block troublesome GPX data scrapping
50 RewriteCond %{REQUEST_METHOD} HEAD
51 RewriteRule ^/trace/\d+/data - [F,L]
56 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
60 # Block changeset scraper
62 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
66 # Block attempts to access old API versions
68 RewriteRule ^/api/0.[12345]/ - [G,L]
71 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
72 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
74 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
78 # Block a changeset that seems to lock things up
80 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
83 # Ignore Vicon Valerus "online" status pings
84 # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
86 RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
87 RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
90 # Force special MIME type for crossdomain.xml files
92 <Files crossdomain.xml>
93 ForceType text/x-cross-domain-policy
97 # Set expiry for assets
100 Header unset Last-Modified
103 ExpiresDefault "access plus 1 year"
104 Header set Cache-Control "immutable, max-age=31536000"
108 # Set expiry for attachments
110 <Location /attachments/>
114 ExpiresDefault "access plus 1 year"
118 # Set expiry for other static content
120 <Location /export/embed.html>
121 ExpiresDefault "access plus 7 days"
124 ExpiresDefault "access plus 10 years"
126 <Location /openlayers/>
127 Header unset Last-Modified
130 Header always set Cache-Control "public, max-age=31536000, immutable"
131 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
137 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
139 PassengerMinInstances 10
140 PassengerMaxRequests 5000
141 PassengerMaxRequestQueueSize 250
142 PassengerPreStart https://www.openstreetmap.org/
143 PassengerAppGroupName rails
144 SetEnv OPENSTREETMAP_STATUS <%= @status %>
145 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
146 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
147 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
148 RedirectPermanent /stats https://planet.openstreetmap.org/statistics
151 # Pass authentication related headers to cgimap
158 # Pass supported calls to cgimap
160 RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
161 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
162 RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
163 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
164 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
165 RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
166 RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
167 RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
168 RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
171 # Redirect trac and wiki requests to the right places
173 RedirectPermanent /trac/ https://trac.openstreetmap.org/
174 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
177 # Redirect requests for various images to the right place
179 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
180 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
183 # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
185 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
186 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
189 # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
191 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
192 RewriteCond %{REQUEST_URI} !^/api/
193 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
197 ServerName openstreetmap.org.uk
198 ServerAlias www.openstreetmap.org.uk
199 ServerAlias openstreetmap.co.uk
200 ServerAlias www.openstreetmap.co.uk
202 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
203 RedirectPermanent / https://www.openstreetmap.org/
209 Header always set Cache-Control "max-age=31536000"
210 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
214 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
216 RewriteCond %{REQUEST_URI} !^/server-status$
217 RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
221 ServerName www.osm.org
223 Header always set Cache-Control "max-age=31536000"
224 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
228 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
230 RewriteCond %{REQUEST_URI} !^/server-status$
231 RewriteRule ^(.*)$ https://www.osm.org$1 [L,NE,R=permanent]
235 ServerName openstreetmap.org
237 Header always set Cache-Control "max-age=31536000"
238 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
242 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
244 RewriteCond %{REQUEST_URI} !^/server-status$
245 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
249 ServerName www.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://www.openstreetmap.org$1 [L,NE,R=permanent]
264 ServerName openstreetmap.org
268 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
269 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
271 Header always set Cache-Control "max-age=31536000"
272 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
274 RedirectPermanent / https://www.openstreetmap.org/
277 <Directory <%= node[:web][:base_directory] %>/rails/public>
280 RewriteCond "%{HTTP:Accept-encoding}" "br"
281 RewriteCond "%{REQUEST_FILENAME}\.br" -s
282 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
284 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
285 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
286 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
288 RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
289 RewriteRule "\.ico\.(br|gz)$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
290 RewriteRule "\.js\.(br|gz)$" "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
291 RewriteRule "\.json\.(br|gz)$" "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
292 RewriteRule "\.svg\.(br|gz)$" "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
293 RewriteRule "\.xml\.(br|gz)$" "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
295 <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
296 Header append Content-Encoding br
297 Header append Vary Accept-Encoding
300 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
301 Header append Content-Encoding gzip
302 Header append Vary Accept-Encoding
306 <Directory /srv/www.openstreetmap.org/static>
310 <Directory /srv/www.openstreetmap.org/rails/app/assets>
314 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>