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
 
  33   # Add the unique ID to the request headers
 
  35   RequestHeader set X-Request-Id %{UNIQUE_ID}e
 
  38   # Remove Proxy request header to mitigate https://httpoxy.org/
 
  40   RequestHeader unset Proxy early
 
  43   # Block troublesome GPX data scrapping
 
  45   RewriteCond %{REQUEST_METHOD} HEAD
 
  46   RewriteRule ^/trace/\d+/data - [F,L]
 
  51   RewriteCond %{HTTP_USER_AGENT} tilesAtHome
 
  55   # Block changeset scraper
 
  57   RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
 
  61   # Block attempts to access old API versions
 
  63   RewriteRule ^/api/0.[12345]/ - [G,L]
 
  66   # Block JOSM revisions  1722-1727 as they have a serious bug that causes
 
  67   # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
 
  69   RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
 
  73   # Block a changeset that seems to lock things up
 
  75   RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
 
  78   # Ignore Vicon Valerus "online" status pings
 
  79   # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
 
  81   RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
 
  82   RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
 
  85   # Force special MIME type for crossdomain.xml files
 
  87   <Files crossdomain.xml>
 
  88     ForceType text/x-cross-domain-policy
 
  92   # Set expiry for assets
 
  95     Header unset Last-Modified
 
  98     ExpiresDefault "access plus 1 year"
 
  99     Header set Cache-Control "immutable, max-age=31536000"
 
 103   # Set expiry for attachments
 
 105   <Location /attachments/>
 
 109     ExpiresDefault "access plus 1 year"
 
 113   # Set expiry for other static content
 
 115   <Location /export/embed.html>
 
 116     ExpiresDefault "access plus 7 days"
 
 119     ExpiresDefault "access plus 10 years"
 
 121   <Location /openlayers/>
 
 122     Header unset Last-Modified
 
 125     Header always set Cache-Control "public, max-age=31536000, immutable"
 
 126     Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 132   DocumentRoot <%= node[:web][:base_directory] %>/rails/public
 
 134   PassengerMinInstances 10
 
 135   PassengerMaxRequests 5000
 
 136   PassengerMaxRequestQueueSize 250
 
 137   PassengerPreStart https://www.openstreetmap.org/
 
 138   PassengerAppGroupName rails
 
 139   SetEnv OPENSTREETMAP_STATUS <%= @status %>
 
 140   SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
 
 141   Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
 
 142   Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
 
 143   RedirectPermanent /stats https://planet.openstreetmap.org/statistics
 
 146   # Pass authentication related headers to cgimap
 
 153   # Pass supported calls to cgimap
 
 155   RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 156   RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
 
 157   RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 158   RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 159   RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 160   RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 161   RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 162   RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 163   RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
 
 166   # Redirect trac and wiki requests to the right places
 
 168   RedirectPermanent /trac/ https://trac.openstreetmap.org/
 
 169   RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
 
 172   # Redirect requests for various images to the right place
 
 174   RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
 
 175   RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
 
 178   # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
 
 180 #  RewriteCond %{HTTP_HOST} =www.openstreetmap.org
 
 181 #  RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
 
 184   # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
 
 186   RewriteCond %{HTTP_HOST} =api.openstreetmap.org
 
 187   RewriteCond %{REQUEST_URI} !^/api/
 
 188   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
 
 192   ServerName openstreetmap.org.uk
 
 193   ServerAlias www.openstreetmap.org.uk
 
 194   ServerAlias openstreetmap.co.uk
 
 195   ServerAlias www.openstreetmap.co.uk
 
 197   RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
 
 198   RedirectPermanent / https://www.openstreetmap.org/
 
 204   Header always set Cache-Control "max-age=31536000"
 
 205   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 209   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
 
 211   RewriteCond %{REQUEST_URI} !^/server-status$
 
 212   RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
 
 216   ServerName www.osm.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://www.osm.org$1 [L,NE,R=permanent]
 
 230   ServerName openstreetmap.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://openstreetmap.org$1 [L,NE,R=permanent]
 
 244   ServerName 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://www.openstreetmap.org$1 [L,NE,R=permanent]
 
 259   ServerName openstreetmap.org
 
 263   SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
 
 264   SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
 
 266   Header always set Cache-Control "max-age=31536000"
 
 267   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
 
 269   RedirectPermanent / https://www.openstreetmap.org/
 
 272 <Directory <%= node[:web][:base_directory] %>/rails/public>
 
 275   RewriteCond "%{HTTP:Accept-encoding}" "br"
 
 276   RewriteCond "%{REQUEST_FILENAME}\.br" -s
 
 277   RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
 
 279   RewriteCond "%{HTTP:Accept-encoding}" "gzip"
 
 280   RewriteCond "%{REQUEST_FILENAME}\.gz" -s
 
 281   RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
 
 283   RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
 
 284   RewriteRule "\.ico\.(br|gz)$"  "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
 
 285   RewriteRule "\.js\.(br|gz)$"  "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
 
 286   RewriteRule "\.json\.(br|gz)$"  "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
 
 287   RewriteRule "\.svg\.(br|gz)$"  "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
 
 288   RewriteRule "\.xml\.(br|gz)$"  "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
 
 290   <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
 
 291     Header append Content-Encoding br
 
 292     Header append Vary Accept-Encoding
 
 295   <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
 
 296     Header append Content-Encoding gzip
 
 297     Header append Vary Accept-Encoding
 
 301 <Directory /srv/www.openstreetmap.org/static>
 
 305 <Directory /srv/www.openstreetmap.org/rails/app/assets>
 
 309 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>