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
22 LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Ts" combined_with_time
23 CustomLog /var/log/apache2/access.log combined_with_time
24 ErrorLog /var/log/apache2/error.log
27 # Turn on various features
33 # Block troublesome GPX data scrapping
35 RewriteCond %{REQUEST_METHOD} HEAD
36 RewriteRule ^/trace/\d+/data - [F,L]
41 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
45 # Block requests for the old 404 map tile
47 RewriteRule ^/openlayers/img/404.png$ - [G,L]
50 # Block attempts to access old API versions
52 RewriteRule ^/api/0.[12345]/ - [G,L]
55 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
56 # lat/lon to be swapped (http://josm.openstreetmap.de/ticket/2804)
58 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
62 # Block a changeset that seems to lock things up
64 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
67 # Force special MIME type for crossdomain.xml files
69 <Files crossdomain.xml>
70 ForceType text/x-cross-domain-policy
74 # Set expiry for assets
77 Header unset Last-Modified
81 ExpiresDefault "access plus 1 year"
85 # Set expiry for attachments
87 <Location /attachments/>
88 Header unset Last-Modified
92 ExpiresDefault "access plus 1 year"
96 # Set expiry for other static content
98 <Location /export/embed.html>
99 ExpiresDefault "access plus 7 days"
102 ExpiresDefault "access plus 10 years"
104 <Location /javascripts/>
105 ExpiresDefault "access plus 10 years"
107 <Location /openlayers/>
108 ExpiresDefault "access plus 7 days"
110 <Location /stylesheets/>
111 ExpiresDefault "access plus 10 years"
115 # Set expiry for Potlatch 1
117 <Location /potlatch/>
118 ExpiresDefault "access plus 7 days"
122 # Set expiry for Potlatch 2
124 <Location /potlatch2/>
125 ExpiresByType application/x-shockwave-flash "access plus 1 day"
126 ExpiresByType application/xml "access plus 1 day"
127 ExpiresByType text/css "access plus 1 day"
128 ExpiresByType image/png "access plus 7 days"
134 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
136 PassengerMinInstances 10
137 PassengerMaxRequests 5000
138 PassengerPreStart http://www.openstreetmap.org/
139 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/images/favicon.ico
140 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
141 Alias /stats /store/rails/stats
142 Alias /user/image /store/rails/user/image
143 Alias /attachments /store/rails/attachments
146 # Preserve the host name when forwarding to the proxy
151 # Set a long timeout - changeset uploads can take a long time
156 # Allow all proxy requests
163 # Pass some other API calls to the backends via a load balancer
165 ProxyPass /api/0.6/map balancer://backend/api/0.6/map
166 ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
167 ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
168 ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
169 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/(upload|download))$ balancer://backend$1
170 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
171 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
172 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
173 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
174 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
175 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
178 # Redirect trac and wiki requests to the right places
180 RedirectPermanent /trac/ http://trac.openstreetmap.org/
181 RedirectPermanent /wiki/ http://wiki.openstreetmap.org/
184 # Redirect requests for various images to the right place
186 RedirectPermanent /images/osm_logo.png http://www.openstreetmap.org/assets/osm_logo.png
187 RedirectPermanent /images/cc_button.png http://www.openstreetmap.org/assets/cc_button.png
190 # Define a load balancer for the backends
192 <Proxy balancer://backend>
193 ProxySet lbmethod=bybusyness
194 BalancerMember http://rails1
195 BalancerMember http://rails2
196 BalancerMember http://rails3
201 # Redirect requests which should be secure to the SSL site
203 RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
204 RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
205 RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
206 RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
207 RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
208 RewriteCond %{REQUEST_URI} ^/user/reset-password$
209 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
212 # Redirect api requests made to www.osm.org to api.osm.org
214 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
215 # RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
218 # Redirect non-api requests made to api.osm.org to www.osm.org
220 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
221 RewriteCond %{REQUEST_URI} !^/api/
222 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
223 <% elsif port == 443 -%>
226 # Redirect api requests to api.osm.org over http
228 RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
231 # Redirect requests which do not need to be secure over http
233 RewriteCond %{REQUEST_URI} !^/login(.html)?$
234 RewriteCond %{REQUEST_URI} !^/user/(new|create-account.html)$
235 RewriteCond %{REQUEST_URI} !^/user/terms$
236 RewriteCond %{REQUEST_URI} !^/user/save$
237 RewriteCond %{REQUEST_URI} !^/user/go_public$
238 RewriteCond %{REQUEST_URI} !^/user/([^/]+)/account$
239 RewriteCond %{REQUEST_URI} !^/user/reset-password$
240 RewriteCond %{REQUEST_URI} !^/preview/
241 RewriteCond %{REQUEST_URI} !^/assets/
242 RewriteCond %{REQUEST_URI} !^/javascripts/
243 RewriteCond %{REQUEST_URI} !^/images/
244 RewriteCond %{REQUEST_URI} !^/stylesheets/
245 RewriteCond %{REQUEST_URI} !^/openlayers/
246 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
252 ServerName openstreetmap.org
253 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
254 ServerAlias openstreetmap.com www.openstreetmap.com
255 ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
256 ServerAlias openstreetmap.net www.openstreetmap.net
257 ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
258 ServerAlias openstreetmaps.org www.openstreetmaps.org
259 ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
260 ServerAlias osm.org www.osm.org
261 ServerAlias maps.osm.org mapz.osm.org
262 ServerAlias openmaps.org www.openmaps.org
263 ServerAlias maps.openmaps.org mapz.openmaps.org
264 ServerAlias openworldmap.org www.openworldmap.org
265 ServerAlias maps.openworldmap.org mapz.openworldmap.org
266 ServerAlias freeosm.org www.freeosm.org
267 ServerAlias maps.freeosm.org mapz.freeosm.org
269 RedirectPermanent / http://www.openstreetmap.org/
273 ServerName openstreetmap.org.uk
274 ServerAlias www.openstreetmap.org.uk
275 ServerAlias openstreetmap.co.uk
276 ServerAlias www.openstreetmap.co.uk
278 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
279 RedirectPermanent / http://www.openstreetmap.org/