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 %{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 # Block troublesome GPX data scrapping
41 RewriteCond %{REQUEST_METHOD} HEAD
42 RewriteRule ^/trace/\d+/data - [F,L]
47 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
51 # Block requests for the old 404 map tile
53 RewriteRule ^/openlayers/img/404.png$ - [G,L]
56 # Block attempts to access old API versions
58 RewriteRule ^/api/0.[12345]/ - [G,L]
61 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
62 # lat/lon to be swapped (http://josm.openstreetmap.de/ticket/2804)
64 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
68 # Block a changeset that seems to lock things up
70 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
73 # Force special MIME type for crossdomain.xml files
75 <Files crossdomain.xml>
76 ForceType text/x-cross-domain-policy
80 # Set expiry for assets
83 Header unset Last-Modified
87 ExpiresDefault "access plus 1 year"
91 # Set expiry for attachments
93 <Location /attachments/>
94 Header unset Last-Modified
98 ExpiresDefault "access plus 1 year"
102 # Set expiry for other static content
104 <Location /export/embed.html>
105 ExpiresDefault "access plus 7 days"
108 ExpiresDefault "access plus 10 years"
110 <Location /javascripts/>
111 ExpiresDefault "access plus 10 years"
113 <Location /openlayers/>
114 ExpiresDefault "access plus 7 days"
116 <Location /stylesheets/>
117 ExpiresDefault "access plus 10 years"
121 # Set expiry for Potlatch 1
123 <Location /potlatch/>
124 ExpiresDefault "access plus 7 days"
128 # Set expiry for Potlatch 2
130 <Location /potlatch2/>
131 ExpiresByType application/x-shockwave-flash "access plus 1 day"
132 ExpiresByType application/xml "access plus 1 day"
133 ExpiresByType text/css "access plus 1 day"
134 ExpiresByType image/png "access plus 7 days"
140 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
142 PassengerMinInstances 10
143 PassengerMaxRequests 5000
144 PassengerMaxRequestQueueSize 250
145 <% if port == 443 -%>
146 PassengerPreStart https://www.openstreetmap.org/
148 PassengerPreStart http://www.openstreetmap.org/
150 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
151 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
152 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
153 Alias /stats /store/rails/stats
154 Alias /user/image /store/rails/user/image
155 Alias /attachments /store/rails/attachments
158 # Preserve the host name when forwarding to the proxy
163 # Set a long timeout - changeset uploads can take a long time
168 # Allow all proxy requests
175 # Pass some other API calls to the backends via a load balancer
177 ProxyPass /api/0.6/map balancer://backend/api/0.6/map
178 ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
179 ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
180 ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
181 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/(upload|download))$ balancer://backend$1
182 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
183 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
184 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
185 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
186 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
187 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
190 # Redirect trac and wiki requests to the right places
192 RedirectPermanent /trac/ http://trac.openstreetmap.org/
193 RedirectPermanent /wiki/ http://wiki.openstreetmap.org/
196 # Redirect requests for various images to the right place
198 RedirectPermanent /images/osm_logo.png http://www.openstreetmap.org/assets/osm_logo.png
199 RedirectPermanent /images/cc_button.png http://www.openstreetmap.org/assets/cc_button.png
202 # Define a load balancer for the backends
204 <Proxy balancer://backend>
205 ProxySet lbmethod=bybusyness
206 <% if port == 443 -%>
207 BalancerMember https://rails1 disablereuse=on
208 BalancerMember https://rails2 disablereuse=on
209 BalancerMember https://rails3 disablereuse=on
211 BalancerMember http://rails1
212 BalancerMember http://rails2
213 BalancerMember http://rails3
219 # Redirect requests which should be secure to https
221 RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
222 RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
223 RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
224 RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
225 RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
226 RewriteCond %{REQUEST_URI} ^/user/reset-password$
227 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
230 # Redirect api requests made to www.osm.org to api.osm.org
232 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
233 # RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
236 # Redirect non-api requests made to api.osm.org to www.osm.org
238 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
239 RewriteCond %{REQUEST_URI} !^/api/
240 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
241 <% elsif port == 443 -%>
244 # Redirect api requests made to www.osm.org to api.osm.org
246 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
247 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
250 # Redirect non-api requests made to api.osm.org to www.osm.org
252 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
253 RewriteCond %{REQUEST_URI} !^/api/
254 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
260 ServerName openstreetmap.org
261 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
262 ServerAlias openstreetmap.com www.openstreetmap.com
263 ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
264 ServerAlias openstreetmap.net www.openstreetmap.net
265 ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
266 ServerAlias openstreetmap.ca www.openstreetmap.ca
267 ServerAlias maps.openstreetmap.ca mapz.openstreetmap.ca
268 ServerAlias openstreetmap.eu www.openstreetmap.eu
269 ServerAlias maps.openstreetmap.eu mapz.openstreetmap.eu
270 ServerAlias openstreetmap.pro www.openstreetmap.pro
271 ServerAlias maps.openstreetmap.pro mapz.openstreetmap.pro
272 ServerAlias openstreetmaps.org www.openstreetmaps.org
273 ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
274 ServerAlias osm.org www.osm.org
275 ServerAlias maps.osm.org mapz.osm.org
276 ServerAlias openmaps.org www.openmaps.org
277 ServerAlias maps.openmaps.org mapz.openmaps.org
278 ServerAlias openstreetmap.io www.openstreetmap.io
279 ServerAlias maps.openstreetmap.io mapz.openstreetmap.io
280 ServerAlias osm.io www.osm.io
281 ServerAlias maps.osm.io mapz.osm.io
282 ServerAlias openworldmap.org www.openworldmap.org
283 ServerAlias maps.openworldmap.org mapz.openworldmap.org
284 ServerAlias freeosm.org www.freeosm.org
285 ServerAlias maps.freeosm.org mapz.freeosm.org
286 ServerAlias open-maps.org www.open-maps.org
287 ServerAlias maps.open-maps.org mapz.open-maps.org
288 ServerAlias open-maps.com www.open-maps.com
289 ServerAlias maps.open-maps.com mapz.open-maps.com
290 ServerAlias osmbugs.org www.osmbugs.org
291 ServerAlias maps.osmbugs.org mapz.osmbugs.org
294 ServerAlias openstreetmap.pm www.openstreetmap.pm
296 RedirectPermanent / http://www.openstreetmap.org/
300 ServerName openstreetmap.org
301 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
305 RedirectPermanent / https://www.openstreetmap.org/
309 ServerName openstreetmap.org.uk
310 ServerAlias www.openstreetmap.org.uk
311 ServerAlias openstreetmap.co.uk
312 ServerAlias www.openstreetmap.co.uk
314 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
315 RedirectPermanent / http://www.openstreetmap.org/
318 <Directory <%= node[:web][:base_directory] %>/rails/public>
322 <Directory /srv/www.openstreetmap.org/rails/app/assets>
326 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
330 <Directory /store/rails/stats>
334 <Directory /store/rails/user/image>
338 <Directory /store/rails/attachments>