1 # DO NOT EDIT - This file is being maintained by Chef
5 # Basic server configuration
7 ServerName <%= node[:fqdn] %>
8 ServerAlias api.openstreetmap.org www.openstreetmap.org 127.0.0.1
9 ServerAdmin webmaster@openstreetmap.org
16 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
17 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
22 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
23 CustomLog /var/log/apache2/access.log combined_with_time
24 ErrorLog /var/log/apache2/error.log
27 # Turn on various features
33 # Add the unique ID to the request headers
35 RequestHeader set X-Request-Id %{UNIQUE_ID}e
38 # Remove Proxy request header to mitigate https://httpoxy.org/
40 RequestHeader unset Proxy early
43 # Block troublesome GPX data scrapping
45 RewriteCond %{REQUEST_METHOD} HEAD
46 RewriteRule ^/trace/\d+/data - [F,L]
51 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
55 # Block changeset scraper
57 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
61 # Block requests for the old 404 map tile
62 # and force cache headers on response
64 <Location /openlayers/img/404.png>
65 Header always set Cache-Control "public, max-age=31536000, immutable"
66 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
71 # Block attempts to access old API versions
73 RewriteRule ^/api/0.[12345]/ - [G,L]
76 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
77 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
79 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
83 # Block a changeset that seems to lock things up
85 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
88 # Force special MIME type for crossdomain.xml files
90 <Files crossdomain.xml>
91 ForceType text/x-cross-domain-policy
95 # Set expiry for assets
98 Header unset Last-Modified
102 ExpiresDefault "access plus 1 year"
106 # Set expiry for attachments
108 <Location /attachments/>
109 Header unset Last-Modified
113 ExpiresDefault "access plus 1 year"
117 # Set expiry for other static content
119 <Location /export/embed.html>
120 ExpiresDefault "access plus 7 days"
123 ExpiresDefault "access plus 10 years"
125 <Location /javascripts/>
126 ExpiresDefault "access plus 10 years"
128 <Location /openlayers/>
129 ExpiresDefault "access plus 7 days"
131 <Location /stylesheets/>
132 ExpiresDefault "access plus 10 years"
136 # Set expiry for Potlatch 1
138 <Location /potlatch/>
139 ExpiresDefault "access plus 7 days"
143 # Set expiry for Potlatch 2
145 <Location /potlatch2/>
146 ExpiresByType application/x-shockwave-flash "access plus 1 day"
147 ExpiresByType application/xml "access plus 1 day"
148 ExpiresByType text/css "access plus 1 day"
149 ExpiresByType image/png "access plus 7 days"
155 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
157 PassengerMinInstances 10
158 PassengerMaxRequests 5000
159 PassengerMaxRequestQueueSize 250
160 PassengerPreStart https://www.openstreetmap.org/
161 PassengerAppGroupName rails
162 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
163 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
164 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
165 Alias /stats /store/rails/stats
166 Alias /user/image /store/rails/user/image
167 Alias /attachments /store/rails/attachments
170 # Preserve the host name when forwarding to the proxy
175 # Set a long timeout - changeset uploads can take a long time
180 # Allow all proxy requests
187 # Pass some other API calls to the backends via a load balancer
189 ProxyPass /api/0.6/map balancer://backend/api/0.6/map
190 ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
191 ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
192 ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
193 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+)$ balancer://backend$1
194 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload)$ balancer://bytemark$1
195 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download)$ balancer://backend$1
196 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
197 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
198 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
199 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
200 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
201 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
204 # Redirect trac and wiki requests to the right places
206 RedirectPermanent /trac/ https://trac.openstreetmap.org/
207 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
210 # Redirect requests for various images to the right place
212 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
213 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
216 # Define a load balancer for the local backends
218 <Proxy balancer://backend>
219 ProxySet lbmethod=bybusyness
220 <% node[:web][:backends].each do |backend| -%>
221 BalancerMember https://<%= backend %> disablereuse=on
226 # Define a load balancer for the IC backends
228 <Proxy balancer://ams>
229 ProxySet lbmethod=bybusyness
230 <% ["rails1.ams", "rails2.ams", "rails3.ams"].each do |backend| -%>
231 BalancerMember https://<%= backend %> disablereuse=on
236 # Define a load balancer for the Bytemark backends
238 <Proxy balancer://bytemark>
239 ProxySet lbmethod=bybusyness
240 <% ["rails4.bm", "rails5.bm"].each do |backend| -%>
241 BalancerMember https://<%= backend %> disablereuse=on
246 # Redirect api requests made to www.osm.org to api.osm.org
248 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
249 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
252 # Redirect non-api requests made to api.osm.org to www.osm.org
254 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
255 RewriteCond %{REQUEST_URI} !^/api/
256 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
260 ServerName openstreetmap.org.uk
261 ServerAlias www.openstreetmap.org.uk
262 ServerAlias openstreetmap.co.uk
263 ServerAlias www.openstreetmap.co.uk
265 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
266 RedirectPermanent / https://www.openstreetmap.org/
270 ServerName openstreetmap.org
273 Header always set Cache-Control "max-age=31536000"
274 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
278 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
280 RewriteCond %{REQUEST_URI} !^/server-status$
281 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
285 ServerName openstreetmap.org
289 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
290 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
292 Header always set Cache-Control "max-age=31536000"
293 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
295 RedirectPermanent / https://www.openstreetmap.org/
298 <Directory <%= node[:web][:base_directory] %>/rails/public>
302 <Directory /srv/www.openstreetmap.org/rails/app/assets>
306 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
310 <Directory /store/rails/stats>
314 <Directory /store/rails/user/image>
318 <Directory /store/rails/attachments>