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 <% if port == 443 -%>
213 BalancerMember https://rails1 disablereuse=on
214 BalancerMember https://rails2 disablereuse=on
215 BalancerMember https://rails3 disablereuse=on
217 BalancerMember http://rails1
218 BalancerMember http://rails2
219 BalancerMember http://rails3
225 # Redirect requests which should be secure to https
227 RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
228 RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
229 RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
230 RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
231 RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
232 RewriteCond %{REQUEST_URI} ^/user/reset-password$
233 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
236 # Redirect api requests made to www.osm.org to api.osm.org
238 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
239 # RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
242 # Redirect non-api requests made to api.osm.org to www.osm.org
244 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
245 RewriteCond %{REQUEST_URI} !^/api/
246 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
247 <% elsif port == 443 -%>
250 # Redirect api requests made to www.osm.org to api.osm.org
252 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
253 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
256 # Redirect non-api requests made to api.osm.org to www.osm.org
258 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
259 RewriteCond %{REQUEST_URI} !^/api/
260 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
266 ServerName openstreetmap.org
267 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
268 ServerAlias openstreetmap.com www.openstreetmap.com
269 ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
270 ServerAlias openstreetmap.net www.openstreetmap.net
271 ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
272 ServerAlias openstreetmap.ca www.openstreetmap.ca
273 ServerAlias maps.openstreetmap.ca mapz.openstreetmap.ca
274 ServerAlias openstreetmap.eu www.openstreetmap.eu
275 ServerAlias maps.openstreetmap.eu mapz.openstreetmap.eu
276 ServerAlias openstreetmap.pro www.openstreetmap.pro
277 ServerAlias maps.openstreetmap.pro mapz.openstreetmap.pro
278 ServerAlias openstreetmaps.org www.openstreetmaps.org
279 ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
280 ServerAlias osm.org www.osm.org
281 ServerAlias maps.osm.org mapz.osm.org
282 ServerAlias openmaps.org www.openmaps.org
283 ServerAlias maps.openmaps.org mapz.openmaps.org
284 ServerAlias openstreetmap.io www.openstreetmap.io
285 ServerAlias maps.openstreetmap.io mapz.openstreetmap.io
286 ServerAlias osm.io www.osm.io
287 ServerAlias maps.osm.io mapz.osm.io
288 ServerAlias openworldmap.org www.openworldmap.org
289 ServerAlias maps.openworldmap.org mapz.openworldmap.org
290 ServerAlias freeosm.org www.freeosm.org
291 ServerAlias maps.freeosm.org mapz.freeosm.org
292 ServerAlias open-maps.org www.open-maps.org
293 ServerAlias maps.open-maps.org mapz.open-maps.org
294 ServerAlias open-maps.com www.open-maps.com
295 ServerAlias maps.open-maps.com mapz.open-maps.com
296 ServerAlias osmbugs.org www.osmbugs.org
297 ServerAlias maps.osmbugs.org mapz.osmbugs.org
300 ServerAlias openstreetmap.pm www.openstreetmap.pm
302 RedirectPermanent / http://www.openstreetmap.org/
306 ServerName openstreetmap.org
307 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
311 RedirectPermanent / https://www.openstreetmap.org/
315 ServerName openstreetmap.org.uk
316 ServerAlias www.openstreetmap.org.uk
317 ServerAlias openstreetmap.co.uk
318 ServerAlias www.openstreetmap.co.uk
320 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
321 RedirectPermanent / http://www.openstreetmap.org/
324 <Directory <%= node[:web][:base_directory] %>/rails/public>
328 <Directory /srv/www.openstreetmap.org/rails/app/assets>
332 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
336 <Directory /store/rails/stats>
340 <Directory /store/rails/user/image>
344 <Directory /store/rails/attachments>