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 # Force extended cache headers on the old 404 map tile
63 <Location /openlayers/img/404.png>
64 Header always set Cache-Control "public, max-age=31536000, immutable"
65 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
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
99 ExpiresDefault "access plus 1 year"
100 Header set Cache-Control "immutable, max-age=31536000"
104 # Set expiry for attachments
106 <Location /attachments/>
110 ExpiresDefault "access plus 1 year"
114 # Set expiry for other static content
116 <Location /export/embed.html>
117 ExpiresDefault "access plus 7 days"
120 ExpiresDefault "access plus 10 years"
122 <Location /openlayers/>
123 ExpiresDefault "access plus 7 days"
129 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
131 PassengerMinInstances 10
132 PassengerMaxRequests 5000
133 PassengerMaxRequestQueueSize 250
134 PassengerPreStart https://www.openstreetmap.org/
135 PassengerAppGroupName rails
136 SetEnv OPENSTREETMAP_STATUS <%= @status %>
137 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
138 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
139 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
140 Alias /stats /store/rails/stats
141 Alias /user/image /store/rails/user/image
142 Alias /attachments /store/rails/attachments
145 # Preserve the host name when forwarding to the proxy
150 # Set a long timeout - changeset uploads can take a long time
155 # Allow all proxy requests
162 # Pass some other API calls to the backends via a load balancer
164 ProxyPassMatch ^(/api/0\.6/map(\.json|\.xml)?)$ balancer://backend$1
165 ProxyPassMatch ^(/api/0\.6/tracepoints)$ balancer://backend$1
166 ProxyPassMatch ^(/api/0\.6/amf/read)$ balancer://backend$1
167 ProxyPassMatch ^(/api/0\.6/swf/trackpoints)$ balancer://backend$1
168 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+(\.json|\.xml)?)$ balancer://backend$1
169 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload(\.json|\.xml)?)$ balancer://amsterdam$1
170 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download(\.json|\.xml)?)$ balancer://backend$1
171 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+(\.json|\.xml)?)$ balancer://backend$1
172 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways|relations)(\.json|\.xml)?)$ balancer://backend$1
173 ProxyPassMatch ^(/api/0\.6/nodes(\.json|\.xml)?)$ balancer://backend$1
174 ProxyPassMatch ^(/api/0\.6/ways(\.json|\.xml)?)$ balancer://backend$1
175 ProxyPassMatch ^(/api/0\.6/relations(\.json|\.xml)?)$ balancer://backend$1
176 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
179 # Redirect trac and wiki requests to the right places
181 RedirectPermanent /trac/ https://trac.openstreetmap.org/
182 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
185 # Redirect requests for various images to the right place
187 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
188 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
191 # Define a load balancer for the local backends
193 <Proxy balancer://backend>
194 ProxySet lbmethod=bybusyness
195 <% Array(node[:web][:backends]).each do |backend| -%>
196 BalancerMember https://<%= backend %> disablereuse=on
201 # Define a load balancer for the Amsterdam backends
203 <Proxy balancer://amsterdam>
204 ProxySet lbmethod=bybusyness
205 <% ["rails1.ams", "rails2.ams", "rails3.ams"].each do |backend| -%>
206 BalancerMember https://<%= backend %> disablereuse=on
211 # Define a load balancer for the Bytemark backends
213 <Proxy balancer://bytemark>
214 ProxySet lbmethod=bybusyness
215 <% ["rails4.bm", "rails5.bm"].each do |backend| -%>
216 BalancerMember https://<%= backend %> disablereuse=on
221 # Redirect api requests made to www.osm.org to api.osm.org
223 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
224 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
227 # Redirect non-api requests made to api.osm.org to www.osm.org
229 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
230 RewriteCond %{REQUEST_URI} !^/api/
231 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
235 ServerName openstreetmap.org.uk
236 ServerAlias www.openstreetmap.org.uk
237 ServerAlias openstreetmap.co.uk
238 ServerAlias www.openstreetmap.co.uk
240 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
241 RedirectPermanent / https://www.openstreetmap.org/
245 ServerName openstreetmap.org
247 Header always set Cache-Control "max-age=31536000"
248 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
252 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
254 RewriteCond %{REQUEST_URI} !^/server-status$
255 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
259 ServerName www.openstreetmap.org
262 Header always set Cache-Control "max-age=31536000"
263 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
267 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
269 RewriteCond %{REQUEST_URI} !^/server-status$
270 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
274 ServerName openstreetmap.org
278 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
279 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
281 Header always set Cache-Control "max-age=31536000"
282 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
284 RedirectPermanent / https://www.openstreetmap.org/
287 <Directory <%= node[:web][:base_directory] %>/rails/public>
290 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
291 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
292 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
294 RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
295 RewriteRule "\.ico\.gz$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1]
296 RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
297 RewriteRule "\.json\.gz$" "-" [T=application/json,E=no-gzip:1]
298 RewriteRule "\.svg\.gz$" "-" [T=image/svg+xml,E=no-gzip:1]
299 RewriteRule "\.xml\.gz$" "-" [T=application/xml,E=no-gzip:1]
301 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
302 Header append Content-Encoding gzip
303 Header append Vary Accept-Encoding
307 <Directory /srv/www.openstreetmap.org/rails/app/assets>
311 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
315 <Directory /store/rails/stats>
319 <Directory /store/rails/user/image>
323 <Directory /store/rails/attachments>