1 # DO NOT EDIT - This file is being maintained by Chef
 
   3 <% [80, 443].each do |port| -%>
 
   4 <VirtualHost *:<%= port %>>
 
   6   # Basic server configuration
 
   8   ServerName <%= node[:fqdn] %>
 
   9   ServerAlias api.openstreetmap.org www.openstreetmap.org
 
  10   ServerAdmin webmaster@openstreetmap.org
 
  23   LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Ts" combined_with_time
 
  24   CustomLog /var/log/apache2/access.log combined_with_time
 
  25   ErrorLog /var/log/apache2/error.log
 
  28   # Turn on various features
 
  34   # Block troublesome GPX data scrapping
 
  36   RewriteCond %{REQUEST_METHOD} HEAD
 
  37   RewriteRule ^/trace/\d+/data - [F,L]
 
  42   RewriteCond %{HTTP_USER_AGENT} tilesAtHome
 
  46   # Block requests for the old 404 map tile
 
  48   RewriteRule ^/openlayers/img/404.png$ - [G,L]
 
  51   # Block attempts to access old API versions
 
  53   RewriteRule ^/api/0.[12345]/ - [G,L]
 
  56   # Block JOSM revisions  1722-1727 as they have a serious bug that causes
 
  57   # lat/lon to be swapped (http://josm.openstreetmap.de/ticket/2804)
 
  59   RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
 
  63   # Block a changeset that seems to lock things up
 
  65   RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
 
  68   # Force special MIME type for crossdomain.xml files
 
  70   <Files crossdomain.xml>
 
  71     ForceType text/x-cross-domain-policy
 
  75   # Set expiry for assets
 
  78     Header unset Last-Modified
 
  82     ExpiresDefault "access plus 1 year"
 
  86   # Set expiry for attachments
 
  88   <Location /attachments/>
 
  89     Header unset Last-Modified
 
  93     ExpiresDefault "access plus 1 year"
 
  97   # Set expiry for other static content
 
  99   <Location /export/embed.html>
 
 100     ExpiresDefault "access plus 7 days"
 
 103     ExpiresDefault "access plus 10 years"
 
 105   <Location /javascripts/>
 
 106     ExpiresDefault "access plus 10 years"
 
 108   <Location /openlayers/>
 
 109     ExpiresDefault "access plus 7 days"
 
 111   <Location /stylesheets/>
 
 112     ExpiresDefault "access plus 10 years"
 
 116   # Set expiry for Potlatch 1
 
 118   <Location /potlatch/>
 
 119     ExpiresDefault "access plus 7 days"
 
 123   # Set expiry for Potlatch 2
 
 125   <Location /potlatch2/>
 
 126     ExpiresByType application/x-shockwave-flash "access plus 1 day"
 
 127     ExpiresByType application/xml "access plus 1 day"
 
 128     ExpiresByType text/css "access plus 1 day"
 
 129     ExpiresByType image/png "access plus 7 days"
 
 135   DocumentRoot <%= node[:web][:base_directory] %>/rails/public
 
 137   PassengerMinInstances 10
 
 138   PassengerMaxRequests 5000
 
 139   PassengerMaxRequestQueueSize 250
 
 140 <% if port == 443 -%>
 
 141   PassengerPreStart https://www.openstreetmap.org/
 
 143   PassengerPreStart http://www.openstreetmap.org/
 
 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] %>/rails/vendor/assets/openlayers
 
 148   Alias /stats /store/rails/stats
 
 149   Alias /user/image /store/rails/user/image
 
 150   Alias /attachments /store/rails/attachments
 
 153   # Preserve the host name when forwarding to the proxy
 
 158   # Set a long timeout - changeset uploads can take a long time
 
 163   # Allow all proxy requests
 
 170   # Pass some other API calls to the backends via a load balancer
 
 172   ProxyPass /api/0.6/map balancer://backend/api/0.6/map
 
 173   ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
 
 174   ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
 
 175   ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
 
 176   ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/(upload|download))$ balancer://backend$1
 
 177   ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
 
 178   ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
 
 179   ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
 
 180   ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
 
 181   ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
 
 182   ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
 
 185   # Redirect trac and wiki requests to the right places
 
 187   RedirectPermanent /trac/ http://trac.openstreetmap.org/
 
 188   RedirectPermanent /wiki/ http://wiki.openstreetmap.org/
 
 191   # Redirect requests for various images to the right place
 
 193   RedirectPermanent /images/osm_logo.png http://www.openstreetmap.org/assets/osm_logo.png
 
 194   RedirectPermanent /images/cc_button.png http://www.openstreetmap.org/assets/cc_button.png
 
 197   # Define a load balancer for the backends
 
 199   <Proxy balancer://backend>
 
 200     ProxySet lbmethod=bybusyness
 
 201 <% if port == 443 -%>
 
 202     BalancerMember https://rails1 disablereuse=on
 
 203     BalancerMember https://rails2 disablereuse=on
 
 204     BalancerMember https://rails3 disablereuse=on
 
 206     BalancerMember http://rails1
 
 207     BalancerMember http://rails2
 
 208     BalancerMember http://rails3
 
 214   # Redirect requests which should be secure to https
 
 216   RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
 
 217   RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
 
 218   RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
 
 219   RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
 
 220   RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
 
 221   RewriteCond %{REQUEST_URI} ^/user/reset-password$
 
 222   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
 
 225   # Redirect api requests made to www.osm.org to api.osm.org
 
 227 #  RewriteCond %{HTTP_HOST} =www.openstreetmap.org
 
 228 #  RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
 
 231   # Redirect non-api requests made to api.osm.org to www.osm.org
 
 233   RewriteCond %{HTTP_HOST} =api.openstreetmap.org
 
 234   RewriteCond %{REQUEST_URI} !^/api/
 
 235   RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
 
 236 <% elsif port == 443 -%>
 
 239   # Redirect api requests made to www.osm.org to api.osm.org
 
 241 #  RewriteCond %{HTTP_HOST} =www.openstreetmap.org
 
 242 #  RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
 
 245   # Redirect non-api requests made to api.osm.org to www.osm.org
 
 247   RewriteCond %{HTTP_HOST} =api.openstreetmap.org
 
 248   RewriteCond %{REQUEST_URI} !^/api/
 
 249   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
 
 255   ServerName openstreetmap.org
 
 256   ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
 
 257   ServerAlias openstreetmap.com www.openstreetmap.com
 
 258   ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
 
 259   ServerAlias openstreetmap.net www.openstreetmap.net
 
 260   ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
 
 261   ServerAlias openstreetmap.ca www.openstreetmap.ca
 
 262   ServerAlias maps.openstreetmap.ca mapz.openstreetmap.ca
 
 263   ServerAlias openstreetmap.eu www.openstreetmap.eu
 
 264   ServerAlias maps.openstreetmap.eu mapz.openstreetmap.eu
 
 265   ServerAlias openstreetmap.pro www.openstreetmap.pro
 
 266   ServerAlias maps.openstreetmap.pro mapz.openstreetmap.pro
 
 267   ServerAlias openstreetmaps.org www.openstreetmaps.org
 
 268   ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
 
 269   ServerAlias osm.org www.osm.org
 
 270   ServerAlias maps.osm.org mapz.osm.org
 
 271   ServerAlias openmaps.org www.openmaps.org
 
 272   ServerAlias maps.openmaps.org mapz.openmaps.org
 
 273   ServerAlias openstreetmap.io www.openstreetmap.io
 
 274   ServerAlias maps.openstreetmap.io mapz.openstreetmap.io
 
 275   ServerAlias osm.io www.osm.io
 
 276   ServerAlias maps.osm.io mapz.osm.io
 
 277   ServerAlias openworldmap.org www.openworldmap.org
 
 278   ServerAlias maps.openworldmap.org mapz.openworldmap.org
 
 279   ServerAlias freeosm.org www.freeosm.org
 
 280   ServerAlias maps.freeosm.org mapz.freeosm.org
 
 281   ServerAlias open-maps.org www.open-maps.org
 
 282   ServerAlias maps.open-maps.org mapz.open-maps.org
 
 283   ServerAlias open-maps.com www.open-maps.com
 
 284   ServerAlias maps.open-maps.com mapz.open-maps.com
 
 285   ServerAlias osmbugs.org www.osmbugs.org
 
 286   ServerAlias maps.osmbugs.org mapz.osmbugs.org
 
 289   ServerAlias openstreetmap.pm www.openstreetmap.pm
 
 291   RedirectPermanent / http://www.openstreetmap.org/
 
 295   ServerName openstreetmap.org
 
 296   ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
 
 300   RedirectPermanent / https://www.openstreetmap.org/
 
 304   ServerName openstreetmap.org.uk
 
 305   ServerAlias www.openstreetmap.org.uk
 
 306   ServerAlias openstreetmap.co.uk
 
 307   ServerAlias www.openstreetmap.co.uk
 
 309   RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
 
 310   RedirectPermanent / http://www.openstreetmap.org/
 
 313 <Directory <%= node[:web][:base_directory] %>/rails/public>
 
 317 <Directory /srv/www.openstreetmap.org/rails/app/assets>
 
 321 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
 
 325 <Directory /store/rails/stats>
 
 329 <Directory /store/rails/user/image>
 
 333 <Directory /store/rails/attachments>