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 attempts to access old API versions
 
  77   RewriteRule ^/api/0.[12345]/ - [G,L]
 
  80   # Block JOSM revisions  1722-1727 as they have a serious bug that causes
 
  81   # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
 
  83   RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
 
  87   # Block a changeset that seems to lock things up
 
  89   RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
 
  92   # Ignore Vicon Valerus "online" status pings
 
  93   # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
 
  95   RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
 
  96   RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
 
  99   # Force special MIME type for crossdomain.xml files
 
 101   <Files crossdomain.xml>
 
 102     ForceType text/x-cross-domain-policy
 
 106   # Set expiry for assets
 
 109     Header unset Last-Modified
 
 112     ExpiresDefault "access plus 1 year"
 
 113     Header set Cache-Control "immutable, max-age=31536000"
 
 117   # Set expiry for attachments
 
 119   <Location /attachments/>
 
 123     ExpiresDefault "access plus 1 year"
 
 127   # Set expiry for other static content
 
 129   <Location /export/embed.html>
 
 130     ExpiresDefault "access plus 7 days"
 
 133     ExpiresDefault "access plus 10 years"
 
 135   <Location /openlayers/>
 
 136     Header unset Last-Modified
 
 139     Header always set Cache-Control "public, max-age=31536000, immutable"
 
 140     Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 146   DocumentRoot <%= node[:web][:base_directory] %>/rails/public
 
 148   PassengerMinInstances 10
 
 149   PassengerMaxRequests 5000
 
 150   PassengerMaxRequestQueueSize 250
 
 151   PassengerPreStart https://www.openstreetmap.org/
 
 152   PassengerAppGroupName rails
 
 153   SetEnv OPENSTREETMAP_STATUS <%= @status %>
 
 154   SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
 
 155   Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
 
 156   Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
 
 157   RedirectPermanent /stats https://planet.openstreetmap.org/statistics
 
 160   # Pass authentication related headers to cgimap
 
 167   # Pass supported calls to cgimap
 
 169   RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 170   RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
 
 171   RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 172   RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 173   RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 174   RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 175   RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 176   RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 177   RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 180   # Redirect trac and wiki requests to the right places
 
 182   RedirectPermanent /trac/ https://trac.openstreetmap.org/
 
 183   RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
 
 186   # Redirect requests for various images to the right place
 
 188   RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
 
 189   RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
 
 192   # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
 
 194 #  RewriteCond %{HTTP_HOST} =www.openstreetmap.org
 
 195 #  RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
 
 198   # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
 
 200   RewriteCond %{HTTP_HOST} =api.openstreetmap.org
 
 201   RewriteCond %{REQUEST_URI} !^/api/
 
 202   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
 
 206   ServerName openstreetmap.org.uk
 
 207   ServerAlias www.openstreetmap.org.uk
 
 208   ServerAlias openstreetmap.co.uk
 
 209   ServerAlias www.openstreetmap.co.uk
 
 211   RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
 
 212   RedirectPermanent / https://www.openstreetmap.org/
 
 218   Header always set Cache-Control "max-age=31536000"
 
 219   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 223   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
 
 225   RewriteCond %{REQUEST_URI} !^/server-status$
 
 226   RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
 
 230   ServerName www.osm.org
 
 232   Header always set Cache-Control "max-age=31536000"
 
 233   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 237   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
 
 239   RewriteCond %{REQUEST_URI} !^/server-status$
 
 240   RewriteRule ^(.*)$ https://www.osm.org$1 [L,NE,R=permanent]
 
 244   ServerName openstreetmap.org
 
 246   Header always set Cache-Control "max-age=31536000"
 
 247   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 251   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
 
 253   RewriteCond %{REQUEST_URI} !^/server-status$
 
 254   RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
 
 258   ServerName www.openstreetmap.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.openstreetmap.org$1 [L,NE,R=permanent]
 
 273   ServerName openstreetmap.org
 
 277   SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
 
 278   SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
 
 280   Header always set Cache-Control "max-age=31536000"
 
 281   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 283   RedirectPermanent / https://www.openstreetmap.org/
 
 286 <Directory <%= node[:web][:base_directory] %>/rails/public>
 
 289   RewriteCond "%{HTTP:Accept-encoding}" "br"
 
 290   RewriteCond "%{REQUEST_FILENAME}\.br" -s
 
 291   RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
 
 293   RewriteCond "%{HTTP:Accept-encoding}" "gzip"
 
 294   RewriteCond "%{REQUEST_FILENAME}\.gz" -s
 
 295   RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
 
 297   RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
 
 298   RewriteRule "\.ico\.(br|gz)$"  "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
 
 299   RewriteRule "\.js\.(br|gz)$"  "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
 
 300   RewriteRule "\.json\.(br|gz)$"  "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
 
 301   RewriteRule "\.svg\.(br|gz)$"  "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
 
 302   RewriteRule "\.xml\.(br|gz)$"  "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
 
 304   <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
 
 305     Header append Content-Encoding br
 
 306     Header append Vary Accept-Encoding
 
 309   <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
 
 310     Header append Content-Encoding gzip
 
 311     Header append Vary Accept-Encoding
 
 315 <Directory /srv/www.openstreetmap.org/static>
 
 319 <Directory /srv/www.openstreetmap.org/rails/app/assets>
 
 323 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>