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 # 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 changeset scraper
53 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
57 # Block requests for the old 404 map tile
59 RewriteRule ^/openlayers/img/404.png$ - [G,L]
62 # Block attempts to access old API versions
64 RewriteRule ^/api/0.[12345]/ - [G,L]
67 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
68 # lat/lon to be swapped (http://josm.openstreetmap.de/ticket/2804)
70 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
74 # Block a changeset that seems to lock things up
76 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
79 # Force special MIME type for crossdomain.xml files
81 <Files crossdomain.xml>
82 ForceType text/x-cross-domain-policy
86 # Set expiry for assets
89 Header unset Last-Modified
93 ExpiresDefault "access plus 1 year"
97 # Set expiry for attachments
99 <Location /attachments/>
100 Header unset Last-Modified
104 ExpiresDefault "access plus 1 year"
108 # Set expiry for other static content
110 <Location /export/embed.html>
111 ExpiresDefault "access plus 7 days"
114 ExpiresDefault "access plus 10 years"
116 <Location /javascripts/>
117 ExpiresDefault "access plus 10 years"
119 <Location /openlayers/>
120 ExpiresDefault "access plus 7 days"
122 <Location /stylesheets/>
123 ExpiresDefault "access plus 10 years"
127 # Set expiry for Potlatch 1
129 <Location /potlatch/>
130 ExpiresDefault "access plus 7 days"
134 # Set expiry for Potlatch 2
136 <Location /potlatch2/>
137 ExpiresByType application/x-shockwave-flash "access plus 1 day"
138 ExpiresByType application/xml "access plus 1 day"
139 ExpiresByType text/css "access plus 1 day"
140 ExpiresByType image/png "access plus 7 days"
146 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
148 PassengerMinInstances 10
149 PassengerMaxRequests 5000
150 PassengerMaxRequestQueueSize 250
151 <% if port == 443 -%>
152 PassengerPreStart https://www.openstreetmap.org/
154 PassengerPreStart http://www.openstreetmap.org/
156 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
157 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
158 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
159 Alias /stats /store/rails/stats
160 Alias /user/image /store/rails/user/image
161 Alias /attachments /store/rails/attachments
164 # Preserve the host name when forwarding to the proxy
169 # Set a long timeout - changeset uploads can take a long time
174 # Allow all proxy requests
181 # Pass some other API calls to the backends via a load balancer
183 ProxyPass /api/0.6/map balancer://backend/api/0.6/map
184 ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
185 ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
186 ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
187 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/(upload|download))$ balancer://backend$1
188 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
189 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
190 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
191 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
192 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
193 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
196 # Redirect trac and wiki requests to the right places
198 RedirectPermanent /trac/ http://trac.openstreetmap.org/
199 RedirectPermanent /wiki/ http://wiki.openstreetmap.org/
202 # Redirect requests for various images to the right place
204 RedirectPermanent /images/osm_logo.png http://www.openstreetmap.org/assets/osm_logo.png
205 RedirectPermanent /images/cc_button.png http://www.openstreetmap.org/assets/cc_button.png
208 # Define a load balancer for the backends
210 <Proxy balancer://backend>
211 ProxySet lbmethod=bybusyness
212 <% node[:web][:backends].each do |backend| -%>
213 <% if port == 443 -%>
214 BalancerMember https://<%= backend %> disablereuse=on
216 BalancerMember http://<%= backend %>
223 # Redirect requests which should be secure to https
225 RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
226 RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
227 RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
228 RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
229 RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
230 RewriteCond %{REQUEST_URI} ^/user/reset-password$
231 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
234 # Redirect api requests made to www.osm.org to api.osm.org
236 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
237 # RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
240 # Redirect non-api requests made to api.osm.org to www.osm.org
242 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
243 RewriteCond %{REQUEST_URI} !^/api/
244 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
245 <% elsif port == 443 -%>
248 # Redirect api requests made to www.osm.org to api.osm.org
250 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
251 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
254 # Redirect non-api requests made to api.osm.org to www.osm.org
256 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
257 RewriteCond %{REQUEST_URI} !^/api/
258 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
264 ServerName openstreetmap.org
265 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
266 ServerAlias openstreetmap.com www.openstreetmap.com
267 ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
268 ServerAlias openstreetmap.net www.openstreetmap.net
269 ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
270 ServerAlias openstreetmap.ca www.openstreetmap.ca
271 ServerAlias maps.openstreetmap.ca mapz.openstreetmap.ca
272 ServerAlias openstreetmap.eu www.openstreetmap.eu
273 ServerAlias maps.openstreetmap.eu mapz.openstreetmap.eu
274 ServerAlias openstreetmap.pro www.openstreetmap.pro
275 ServerAlias maps.openstreetmap.pro mapz.openstreetmap.pro
276 ServerAlias openstreetmaps.org www.openstreetmaps.org
277 ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
278 ServerAlias osm.org www.osm.org
279 ServerAlias maps.osm.org mapz.osm.org
280 ServerAlias openmaps.org www.openmaps.org
281 ServerAlias maps.openmaps.org mapz.openmaps.org
282 ServerAlias openstreetmap.io www.openstreetmap.io
283 ServerAlias maps.openstreetmap.io mapz.openstreetmap.io
284 ServerAlias osm.io www.osm.io
285 ServerAlias maps.osm.io mapz.osm.io
286 ServerAlias openworldmap.org www.openworldmap.org
287 ServerAlias maps.openworldmap.org mapz.openworldmap.org
288 ServerAlias freeosm.org www.freeosm.org
289 ServerAlias maps.freeosm.org mapz.freeosm.org
290 ServerAlias open-maps.org www.open-maps.org
291 ServerAlias maps.open-maps.org mapz.open-maps.org
292 ServerAlias open-maps.com www.open-maps.com
293 ServerAlias maps.open-maps.com mapz.open-maps.com
294 ServerAlias osmbugs.org www.osmbugs.org
295 ServerAlias maps.osmbugs.org mapz.osmbugs.org
298 ServerAlias openstreetmap.pm www.openstreetmap.pm
300 RedirectPermanent / http://www.openstreetmap.org/
304 ServerName openstreetmap.org
305 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
309 RedirectPermanent / https://www.openstreetmap.org/
313 ServerName openstreetmap.org.uk
314 ServerAlias www.openstreetmap.org.uk
315 ServerAlias openstreetmap.co.uk
316 ServerAlias www.openstreetmap.co.uk
318 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
319 RedirectPermanent / http://www.openstreetmap.org/
322 <Directory <%= node[:web][:base_directory] %>/rails/public>
326 <Directory /srv/www.openstreetmap.org/rails/app/assets>
330 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
334 <Directory /store/rails/stats>
338 <Directory /store/rails/user/image>
342 <Directory /store/rails/attachments>