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 unset Last-Modified
67 Header always set Cache-Control "public, max-age=31536000, immutable"
68 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
72 # Block attempts to access old API versions
74 RewriteRule ^/api/0.[12345]/ - [G,L]
77 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
78 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
80 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
84 # Block a changeset that seems to lock things up
86 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
89 # Force special MIME type for crossdomain.xml files
91 <Files crossdomain.xml>
92 ForceType text/x-cross-domain-policy
96 # Set expiry for assets
99 Header unset Last-Modified
102 ExpiresDefault "access plus 1 year"
103 Header set Cache-Control "immutable, max-age=31536000"
107 # Set expiry for attachments
109 <Location /attachments/>
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 /openlayers/>
126 Header unset Last-Modified
129 ExpiresDefault "access plus 7 days"
135 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
137 PassengerMinInstances 10
138 PassengerMaxRequests 5000
139 PassengerMaxRequestQueueSize 250
140 PassengerPreStart https://www.openstreetmap.org/
141 PassengerAppGroupName rails
142 SetEnv OPENSTREETMAP_STATUS <%= @status %>
143 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
144 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
145 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
146 Alias /stats /store/rails/stats
147 Alias /user/image /store/rails/user/image
148 Alias /attachments /store/rails/attachments
151 # Preserve the host name when forwarding to the proxy
156 # Set a long timeout - changeset uploads can take a long time
161 # Allow all proxy requests
168 # Pass some other API calls to the backends via a load balancer
170 ProxyPassMatch ^(/api/0\.6/map(\.json|\.xml)?)$ balancer://backend$1
171 ProxyPassMatch ^(/api/0\.6/tracepoints)$ balancer://backend$1
172 ProxyPassMatch ^(/api/0\.6/amf/read)$ balancer://backend$1
173 ProxyPassMatch ^(/api/0\.6/swf/trackpoints)$ balancer://backend$1
174 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+(\.json|\.xml)?)$ balancer://backend$1
175 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload(\.json|\.xml)?)$ balancer://amsterdam$1
176 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download(\.json|\.xml)?)$ balancer://backend$1
177 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+(\.json|\.xml)?)$ balancer://backend$1
178 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways|relations)(\.json|\.xml)?)$ balancer://backend$1
179 ProxyPassMatch ^(/api/0\.6/nodes(\.json|\.xml)?)$ balancer://backend$1
180 ProxyPassMatch ^(/api/0\.6/ways(\.json|\.xml)?)$ balancer://backend$1
181 ProxyPassMatch ^(/api/0\.6/relations(\.json|\.xml)?)$ balancer://backend$1
182 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
185 # Redirect trac and wiki requests to the right places
187 RedirectPermanent /trac/ https://trac.openstreetmap.org/
188 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
191 # Redirect requests for various images to the right place
193 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
194 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
197 # Define a load balancer for the local backends
199 <Proxy balancer://backend>
200 ProxySet lbmethod=bybusyness
201 <% Array(node[:web][:backends]).each do |backend| -%>
202 BalancerMember https://<%= backend %> disablereuse=on
207 # Define a load balancer for the Amsterdam backends
209 <Proxy balancer://amsterdam>
210 ProxySet lbmethod=bybusyness
211 <% ["rails1.ams", "rails2.ams", "rails3.ams"].each do |backend| -%>
212 BalancerMember https://<%= backend %> disablereuse=on
217 # Define a load balancer for the Bytemark backends
219 <Proxy balancer://bytemark>
220 ProxySet lbmethod=bybusyness
221 <% ["rails4.bm", "rails5.bm"].each do |backend| -%>
222 BalancerMember https://<%= backend %> disablereuse=on
227 # Redirect api requests made to www.osm.org to api.osm.org
229 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
230 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
233 # Redirect non-api requests made to api.osm.org to www.osm.org
235 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
236 RewriteCond %{REQUEST_URI} !^/api/
237 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
241 ServerName openstreetmap.org.uk
242 ServerAlias www.openstreetmap.org.uk
243 ServerAlias openstreetmap.co.uk
244 ServerAlias www.openstreetmap.co.uk
246 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
247 RedirectPermanent / https://www.openstreetmap.org/
251 ServerName openstreetmap.org
253 Header always set Cache-Control "max-age=31536000"
254 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
258 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
260 RewriteCond %{REQUEST_URI} !^/server-status$
261 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
265 ServerName www.openstreetmap.org
268 Header always set Cache-Control "max-age=31536000"
269 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
273 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
275 RewriteCond %{REQUEST_URI} !^/server-status$
276 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
280 ServerName openstreetmap.org
284 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
285 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
287 Header always set Cache-Control "max-age=31536000"
288 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
290 RedirectPermanent / https://www.openstreetmap.org/
293 <Directory <%= node[:web][:base_directory] %>/rails/public>
296 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
297 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
298 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
300 RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
301 RewriteRule "\.ico\.gz$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1]
302 RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
303 RewriteRule "\.json\.gz$" "-" [T=application/json,E=no-gzip:1]
304 RewriteRule "\.svg\.gz$" "-" [T=image/svg+xml,E=no-gzip:1]
305 RewriteRule "\.xml\.gz$" "-" [T=application/xml,E=no-gzip:1]
307 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
308 Header append Content-Encoding gzip
309 Header append Vary Accept-Encoding
313 <Directory /srv/www.openstreetmap.org/rails/app/assets>
317 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
321 <Directory /store/rails/stats>
325 <Directory /store/rails/user/image>
329 <Directory /store/rails/attachments>