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 attempts to access old API versions
63 RewriteRule ^/api/0.[12345]/ - [G,L]
66 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
67 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
69 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
73 # Block a changeset that seems to lock things up
75 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
78 # Force special MIME type for crossdomain.xml files
80 <Files crossdomain.xml>
81 ForceType text/x-cross-domain-policy
85 # Set expiry for assets
88 Header unset Last-Modified
91 ExpiresDefault "access plus 1 year"
92 Header set Cache-Control "immutable, max-age=31536000"
96 # Set expiry for attachments
98 <Location /attachments/>
102 ExpiresDefault "access plus 1 year"
106 # Set expiry for other static content
108 <Location /export/embed.html>
109 ExpiresDefault "access plus 7 days"
112 ExpiresDefault "access plus 10 years"
114 <Location /openlayers/>
115 Header unset Last-Modified
118 Header always set Cache-Control "public, max-age=31536000, immutable"
119 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
125 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
127 PassengerMinInstances 10
128 PassengerMaxRequests 5000
129 PassengerMaxRequestQueueSize 250
130 PassengerPreStart https://www.openstreetmap.org/
131 PassengerAppGroupName rails
132 SetEnv OPENSTREETMAP_STATUS <%= @status %>
133 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
134 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
135 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
136 Alias /stats /store/rails/stats
137 Alias /user/image /store/rails/user/image
138 Alias /attachments /store/rails/attachments
141 # Preserve the host name when forwarding to the proxy
146 # Set a long timeout - changeset uploads can take a long time
151 # Allow all proxy requests
158 # Pass some other API calls to the backends via a load balancer
160 ProxyPassMatch ^(/api/0\.6/map(\.json|\.xml)?)$ balancer://backend$1
161 ProxyPassMatch ^(/api/0\.6/tracepoints)$ balancer://backend$1
162 ProxyPassMatch ^(/api/0\.6/amf/read)$ balancer://backend$1
163 ProxyPassMatch ^(/api/0\.6/swf/trackpoints)$ balancer://backend$1
164 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+(\.json|\.xml)?)$ balancer://backend$1
165 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload(\.json|\.xml)?)$ balancer://amsterdam$1
166 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download(\.json|\.xml)?)$ balancer://backend$1
167 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+(\.json|\.xml)?)$ balancer://backend$1
168 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways|relations)(\.json|\.xml)?)$ balancer://backend$1
169 ProxyPassMatch ^(/api/0\.6/nodes(\.json|\.xml)?)$ balancer://backend$1
170 ProxyPassMatch ^(/api/0\.6/ways(\.json|\.xml)?)$ balancer://backend$1
171 ProxyPassMatch ^(/api/0\.6/relations(\.json|\.xml)?)$ balancer://backend$1
172 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
175 # Redirect trac and wiki requests to the right places
177 RedirectPermanent /trac/ https://trac.openstreetmap.org/
178 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
181 # Redirect requests for various images to the right place
183 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
184 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
187 # Define a load balancer for the local backends
189 <Proxy balancer://backend>
190 ProxySet lbmethod=bybusyness
191 <% Array(node[:web][:backends]).each do |backend| -%>
192 BalancerMember https://<%= backend %> disablereuse=on
197 # Define a load balancer for the Amsterdam backends
199 <Proxy balancer://amsterdam>
200 ProxySet lbmethod=bybusyness
201 <% ["rails1.ams", "rails2.ams", "rails3.ams"].each do |backend| -%>
202 BalancerMember https://<%= backend %> disablereuse=on
207 # Define a load balancer for the Bytemark backends
209 <Proxy balancer://bytemark>
210 ProxySet lbmethod=bybusyness
211 <% ["rails4.bm", "rails5.bm"].each do |backend| -%>
212 BalancerMember https://<%= backend %> disablereuse=on
217 # Redirect api requests made to www.osm.org to api.osm.org
219 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
220 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
223 # Redirect non-api requests made to api.osm.org to www.osm.org
225 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
226 RewriteCond %{REQUEST_URI} !^/api/
227 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
231 ServerName openstreetmap.org.uk
232 ServerAlias www.openstreetmap.org.uk
233 ServerAlias openstreetmap.co.uk
234 ServerAlias www.openstreetmap.co.uk
236 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
237 RedirectPermanent / https://www.openstreetmap.org/
241 ServerName openstreetmap.org
243 Header always set Cache-Control "max-age=31536000"
244 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
248 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
250 RewriteCond %{REQUEST_URI} !^/server-status$
251 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
255 ServerName www.openstreetmap.org
258 Header always set Cache-Control "max-age=31536000"
259 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
263 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
265 RewriteCond %{REQUEST_URI} !^/server-status$
266 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
270 ServerName openstreetmap.org
274 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
275 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
277 Header always set Cache-Control "max-age=31536000"
278 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
280 RedirectPermanent / https://www.openstreetmap.org/
283 <Directory <%= node[:web][:base_directory] %>/rails/public>
286 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
287 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
288 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
290 RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
291 RewriteRule "\.ico\.gz$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1]
292 RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
293 RewriteRule "\.json\.gz$" "-" [T=application/json,E=no-gzip:1]
294 RewriteRule "\.svg\.gz$" "-" [T=image/svg+xml,E=no-gzip:1]
295 RewriteRule "\.xml\.gz$" "-" [T=application/xml,E=no-gzip:1]
297 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
298 Header append Content-Encoding gzip
299 Header append Vary Accept-Encoding
303 <Directory /srv/www.openstreetmap.org/rails/app/assets>
307 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
311 <Directory /store/rails/stats>
315 <Directory /store/rails/user/image>
319 <Directory /store/rails/attachments>