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\" %Dus %{UNIQUE_ID}e %{SSL_PROTOCOL}x %{SSL_CIPHER}x" 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 # Add the unique ID to the request headers
36 RequestHeader set X-Request-Id %{UNIQUE_ID}e
39 # Remove Proxy request header to mitigate https://httpoxy.org/
41 RequestHeader unset Proxy early
44 # Block troublesome GPX data scrapping
46 RewriteCond %{REQUEST_METHOD} HEAD
47 RewriteRule ^/trace/\d+/data - [F,L]
52 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
56 # Block changeset scraper
58 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
62 # Block requests for the old 404 map tile
64 RewriteRule ^/openlayers/img/404.png$ - [G,L]
67 # Block attempts to access old API versions
69 RewriteRule ^/api/0.[12345]/ - [G,L]
72 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
73 # lat/lon to be swapped (http://josm.openstreetmap.de/ticket/2804)
75 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
79 # Block a changeset that seems to lock things up
81 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
84 # Force special MIME type for crossdomain.xml files
86 <Files crossdomain.xml>
87 ForceType text/x-cross-domain-policy
91 # Set expiry for assets
94 Header unset Last-Modified
98 ExpiresDefault "access plus 1 year"
102 # Set expiry for attachments
104 <Location /attachments/>
105 Header unset Last-Modified
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 /javascripts/>
122 ExpiresDefault "access plus 10 years"
124 <Location /openlayers/>
125 ExpiresDefault "access plus 7 days"
127 <Location /stylesheets/>
128 ExpiresDefault "access plus 10 years"
132 # Set expiry for Potlatch 1
134 <Location /potlatch/>
135 ExpiresDefault "access plus 7 days"
139 # Set expiry for Potlatch 2
141 <Location /potlatch2/>
142 ExpiresByType application/x-shockwave-flash "access plus 1 day"
143 ExpiresByType application/xml "access plus 1 day"
144 ExpiresByType text/css "access plus 1 day"
145 ExpiresByType image/png "access plus 7 days"
151 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
153 PassengerMinInstances 10
154 PassengerMaxRequests 5000
155 PassengerMaxRequestQueueSize 250
156 <% if port == 443 -%>
157 PassengerPreStart https://www.openstreetmap.org/
159 PassengerPreStart http://www.openstreetmap.org/
161 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
162 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
163 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
164 Alias /stats /store/rails/stats
165 Alias /user/image /store/rails/user/image
166 Alias /attachments /store/rails/attachments
169 # Preserve the host name when forwarding to the proxy
174 # Set a long timeout - changeset uploads can take a long time
179 # Allow all proxy requests
186 # Pass some other API calls to the backends via a load balancer
188 ProxyPass /api/0.6/map balancer://bytemark/api/0.6/map
189 ProxyPass /api/0.6/tracepoints balancer://bytemark/api/0.6/tracepoints
190 ProxyPass /api/0.6/amf/read balancer://bytemark/api/0.6/amf/read
191 ProxyPass /api/0.6/swf/trackpoints balancer://bytemark/api/0.6/swf/trackpoints
192 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload)$ balancer://bytemark$1
193 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download)$ balancer://bytemark$1
194 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://bytemark$1
195 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://bytemark$1
196 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
197 ProxyPass /api/0.6/ways balancer://bytemark/api/0.6/ways
198 ProxyPass /api/0.6/relations balancer://bytemark/api/0.6/relations
199 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://bytemark$1
202 # Redirect trac and wiki requests to the right places
204 RedirectPermanent /trac/ http://trac.openstreetmap.org/
205 RedirectPermanent /wiki/ http://wiki.openstreetmap.org/
208 # Redirect requests for various images to the right place
210 RedirectPermanent /images/osm_logo.png http://www.openstreetmap.org/assets/osm_logo.png
211 RedirectPermanent /images/cc_button.png http://www.openstreetmap.org/assets/cc_button.png
214 # Define a load balancer for the local backends
216 <Proxy balancer://backend>
217 ProxySet lbmethod=bybusyness
218 <% (node[:web][:backends] + ["rails4.bm", "rails5.bm"]).each do |backend| -%>
219 <% if port == 443 -%>
220 BalancerMember https://<%= backend %> disablereuse=on
222 BalancerMember http://<%= backend %>
228 # Define a load balancer for the Bytemark backends
230 <Proxy balancer://bytemark>
231 ProxySet lbmethod=bybusyness
232 <% ["rails4.bm", "rails5.bm"].each do |backend| -%>
233 <% if port == 443 -%>
234 BalancerMember https://<%= backend %> disablereuse=on
236 BalancerMember http://<%= backend %>
243 # Redirect requests which should be secure to https
245 RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
246 RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
247 RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
248 RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
249 RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
250 RewriteCond %{REQUEST_URI} ^/user/reset-password$
251 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
254 # Redirect api requests made to www.osm.org to api.osm.org
256 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
257 # RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
260 # Redirect non-api requests made to api.osm.org to www.osm.org
262 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
263 RewriteCond %{REQUEST_URI} !^/api/
264 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
265 <% elsif port == 443 -%>
268 # Redirect api requests made to www.osm.org to api.osm.org
270 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
271 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
274 # Redirect non-api requests made to api.osm.org to www.osm.org
276 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
277 RewriteCond %{REQUEST_URI} !^/api/
278 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
284 ServerName openstreetmap.org
285 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
286 ServerAlias openstreetmap.com www.openstreetmap.com
287 ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
288 ServerAlias openstreetmap.net www.openstreetmap.net
289 ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
290 ServerAlias openstreetmap.ca www.openstreetmap.ca
291 ServerAlias maps.openstreetmap.ca mapz.openstreetmap.ca
292 ServerAlias openstreetmap.eu www.openstreetmap.eu
293 ServerAlias maps.openstreetmap.eu mapz.openstreetmap.eu
294 ServerAlias openstreetmap.pro www.openstreetmap.pro
295 ServerAlias maps.openstreetmap.pro mapz.openstreetmap.pro
296 ServerAlias openstreetmaps.org www.openstreetmaps.org
297 ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
298 ServerAlias osm.org www.osm.org
299 ServerAlias maps.osm.org mapz.osm.org
300 ServerAlias openmaps.org www.openmaps.org
301 ServerAlias maps.openmaps.org mapz.openmaps.org
302 ServerAlias openstreetmap.io www.openstreetmap.io
303 ServerAlias maps.openstreetmap.io mapz.openstreetmap.io
304 ServerAlias osm.io www.osm.io
305 ServerAlias maps.osm.io mapz.osm.io
306 ServerAlias openworldmap.org www.openworldmap.org
307 ServerAlias maps.openworldmap.org mapz.openworldmap.org
308 ServerAlias freeosm.org www.freeosm.org
309 ServerAlias maps.freeosm.org mapz.freeosm.org
310 ServerAlias open-maps.org www.open-maps.org
311 ServerAlias maps.open-maps.org mapz.open-maps.org
312 ServerAlias open-maps.com www.open-maps.com
313 ServerAlias maps.open-maps.com mapz.open-maps.com
314 ServerAlias osmbugs.org www.osmbugs.org
315 ServerAlias maps.osmbugs.org mapz.osmbugs.org
318 ServerAlias openstreetmap.pm www.openstreetmap.pm
320 RedirectPermanent / http://www.openstreetmap.org/
324 ServerName openstreetmap.org
325 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
329 RedirectPermanent / https://www.openstreetmap.org/
333 ServerName openstreetmap.org.uk
334 ServerAlias www.openstreetmap.org.uk
335 ServerAlias openstreetmap.co.uk
336 ServerAlias www.openstreetmap.co.uk
338 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
339 RedirectPermanent / http://www.openstreetmap.org/
342 <Directory <%= node[:web][:base_directory] %>/rails/public>
346 <Directory /srv/www.openstreetmap.org/rails/app/assets>
350 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
354 <Directory /store/rails/stats>
358 <Directory /store/rails/user/image>
362 <Directory /store/rails/attachments>