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 127.0.0.1
10 ServerAdmin webmaster@openstreetmap.org
18 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
19 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
25 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
26 CustomLog /var/log/apache2/access.log combined_with_time
27 ErrorLog /var/log/apache2/error.log
30 # Turn on various features
36 # Add the unique ID to the request headers
38 RequestHeader set X-Request-Id %{UNIQUE_ID}e
41 # Remove Proxy request header to mitigate https://httpoxy.org/
43 RequestHeader unset Proxy early
46 # Block troublesome GPX data scrapping
48 RewriteCond %{REQUEST_METHOD} HEAD
49 RewriteRule ^/trace/\d+/data - [F,L]
54 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
58 # Block changeset scraper
60 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
64 # Block requests for the old 404 map tile
66 RewriteRule ^/openlayers/img/404.png$ - [G,L]
69 # Block attempts to access old API versions
71 RewriteRule ^/api/0.[12345]/ - [G,L]
74 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
75 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
77 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
81 # Block a changeset that seems to lock things up
83 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
86 # Force special MIME type for crossdomain.xml files
88 <Files crossdomain.xml>
89 ForceType text/x-cross-domain-policy
93 # Set expiry for assets
96 Header unset Last-Modified
100 ExpiresDefault "access plus 1 year"
104 # Set expiry for attachments
106 <Location /attachments/>
107 Header unset Last-Modified
111 ExpiresDefault "access plus 1 year"
115 # Set expiry for other static content
117 <Location /export/embed.html>
118 ExpiresDefault "access plus 7 days"
121 ExpiresDefault "access plus 10 years"
123 <Location /javascripts/>
124 ExpiresDefault "access plus 10 years"
126 <Location /openlayers/>
127 ExpiresDefault "access plus 7 days"
129 <Location /stylesheets/>
130 ExpiresDefault "access plus 10 years"
134 # Set expiry for Potlatch 1
136 <Location /potlatch/>
137 ExpiresDefault "access plus 7 days"
141 # Set expiry for Potlatch 2
143 <Location /potlatch2/>
144 ExpiresByType application/x-shockwave-flash "access plus 1 day"
145 ExpiresByType application/xml "access plus 1 day"
146 ExpiresByType text/css "access plus 1 day"
147 ExpiresByType image/png "access plus 7 days"
153 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
155 PassengerMinInstances 10
156 PassengerMaxRequests 5000
157 PassengerMaxRequestQueueSize 250
158 <% if port == 443 -%>
159 PassengerPreStart https://www.openstreetmap.org/
161 PassengerPreStart http://www.openstreetmap.org/
163 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
164 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
165 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
166 Alias /stats /store/rails/stats
167 Alias /user/image /store/rails/user/image
168 Alias /attachments /store/rails/attachments
171 # Preserve the host name when forwarding to the proxy
176 # Set a long timeout - changeset uploads can take a long time
181 # Allow all proxy requests
188 # Pass some other API calls to the backends via a load balancer
190 ProxyPass /api/0.6/map balancer://backend/api/0.6/map
191 ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
192 ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
193 ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
194 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+)$ balancer://backend$1
195 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload)$ balancer://ic$1
196 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download)$ balancer://backend$1
197 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
198 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
199 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
200 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
201 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
202 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
205 # Redirect ACME certificate challenges
207 RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
210 # Redirect trac and wiki requests to the right places
212 RedirectPermanent /trac/ https://trac.openstreetmap.org/
213 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
216 # Redirect requests for various images to the right place
218 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
219 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
222 # Define a load balancer for the local backends
224 <Proxy balancer://backend>
225 ProxySet lbmethod=bybusyness
226 <% node[:web][:backends].each do |backend| -%>
227 <% if port == 443 -%>
228 BalancerMember https://<%= backend %> disablereuse=on
230 BalancerMember http://<%= backend %>
236 # Define a load balancer for the IC backends
238 <Proxy balancer://ic>
239 ProxySet lbmethod=bybusyness
240 <% ["rails1.ic", "rails2.ic", "rails3.ic"].each do |backend| -%>
241 <% if port == 443 -%>
242 BalancerMember https://<%= backend %> disablereuse=on
244 BalancerMember http://<%= backend %>
251 # Redirect requests which should be secure to https
253 RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
254 RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
255 RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
256 RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
257 RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
258 RewriteCond %{REQUEST_URI} ^/user/reset-password$
259 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
262 # Redirect api requests made to www.osm.org to api.osm.org
264 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
265 # RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
268 # Redirect non-api requests made to api.osm.org to www.osm.org
270 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
271 RewriteCond %{REQUEST_URI} !^/api/
272 RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
273 <% elsif port == 443 -%>
276 # Redirect api requests made to www.osm.org to api.osm.org
278 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
279 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
282 # Redirect non-api requests made to api.osm.org to www.osm.org
284 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
285 RewriteCond %{REQUEST_URI} !^/api/
286 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
292 ServerName openstreetmap.org.uk
293 ServerAlias www.openstreetmap.org.uk
294 ServerAlias openstreetmap.co.uk
295 ServerAlias www.openstreetmap.co.uk
297 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
298 RedirectPermanent / https://www.openstreetmap.org/
302 ServerName openstreetmap.org
307 RewriteCond %{REQUEST_URI} !^/server-status$
308 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
312 ServerName openstreetmap.org
316 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
317 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
319 RedirectPermanent / https://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>