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)$ balancer://bytemark$1
188 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download)$ balancer://backend$1
189 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
190 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
191 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
192 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
193 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
194 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
197 # Redirect trac and wiki requests to the right places
199 RedirectPermanent /trac/ http://trac.openstreetmap.org/
200 RedirectPermanent /wiki/ http://wiki.openstreetmap.org/
203 # Redirect requests for various images to the right place
205 RedirectPermanent /images/osm_logo.png http://www.openstreetmap.org/assets/osm_logo.png
206 RedirectPermanent /images/cc_button.png http://www.openstreetmap.org/assets/cc_button.png
209 # Define a load balancer for the local backends
211 <Proxy balancer://backend>
212 ProxySet lbmethod=bybusyness
213 <% node[:web][:backends].each do |backend| -%>
214 <% if port == 443 -%>
215 BalancerMember https://<%= backend %> disablereuse=on
217 BalancerMember http://<%= backend %>
223 # Define a load balancer for the Bytemark backends
225 <Proxy balancer://bytemark>
226 ProxySet lbmethod=bybusyness
227 <% ["rails4.bm", "rails5.bm"].each do |backend| -%>
228 <% if port == 443 -%>
229 BalancerMember https://<%= backend %> disablereuse=on
231 BalancerMember http://<%= backend %>
238 # Redirect requests which should be secure to https
240 RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
241 RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
242 RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
243 RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
244 RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
245 RewriteCond %{REQUEST_URI} ^/user/reset-password$
246 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
249 # Redirect api requests made to www.osm.org to api.osm.org
251 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
252 # RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
255 # Redirect non-api requests made to api.osm.org to www.osm.org
257 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
258 RewriteCond %{REQUEST_URI} !^/api/
259 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
260 <% elsif port == 443 -%>
263 # Redirect api requests made to www.osm.org to api.osm.org
265 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
266 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
269 # Redirect non-api requests made to api.osm.org to www.osm.org
271 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
272 RewriteCond %{REQUEST_URI} !^/api/
273 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
279 ServerName openstreetmap.org
280 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
281 ServerAlias openstreetmap.com www.openstreetmap.com
282 ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
283 ServerAlias openstreetmap.net www.openstreetmap.net
284 ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
285 ServerAlias openstreetmap.ca www.openstreetmap.ca
286 ServerAlias maps.openstreetmap.ca mapz.openstreetmap.ca
287 ServerAlias openstreetmap.eu www.openstreetmap.eu
288 ServerAlias maps.openstreetmap.eu mapz.openstreetmap.eu
289 ServerAlias openstreetmap.pro www.openstreetmap.pro
290 ServerAlias maps.openstreetmap.pro mapz.openstreetmap.pro
291 ServerAlias openstreetmaps.org www.openstreetmaps.org
292 ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
293 ServerAlias osm.org www.osm.org
294 ServerAlias maps.osm.org mapz.osm.org
295 ServerAlias openmaps.org www.openmaps.org
296 ServerAlias maps.openmaps.org mapz.openmaps.org
297 ServerAlias openstreetmap.io www.openstreetmap.io
298 ServerAlias maps.openstreetmap.io mapz.openstreetmap.io
299 ServerAlias osm.io www.osm.io
300 ServerAlias maps.osm.io mapz.osm.io
301 ServerAlias openworldmap.org www.openworldmap.org
302 ServerAlias maps.openworldmap.org mapz.openworldmap.org
303 ServerAlias freeosm.org www.freeosm.org
304 ServerAlias maps.freeosm.org mapz.freeosm.org
305 ServerAlias open-maps.org www.open-maps.org
306 ServerAlias maps.open-maps.org mapz.open-maps.org
307 ServerAlias open-maps.com www.open-maps.com
308 ServerAlias maps.open-maps.com mapz.open-maps.com
309 ServerAlias osmbugs.org www.osmbugs.org
310 ServerAlias maps.osmbugs.org mapz.osmbugs.org
313 ServerAlias openstreetmap.pm www.openstreetmap.pm
315 RedirectPermanent / http://www.openstreetmap.org/
319 ServerName openstreetmap.org
320 ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
324 RedirectPermanent / https://www.openstreetmap.org/
328 ServerName openstreetmap.org.uk
329 ServerAlias www.openstreetmap.org.uk
330 ServerAlias openstreetmap.co.uk
331 ServerAlias www.openstreetmap.co.uk
333 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
334 RedirectPermanent / http://www.openstreetmap.org/
337 <Directory <%= node[:web][:base_directory] %>/rails/public>
341 <Directory /srv/www.openstreetmap.org/rails/app/assets>
345 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
349 <Directory /store/rails/stats>
353 <Directory /store/rails/user/image>
357 <Directory /store/rails/attachments>