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
63 RewriteRule ^/openlayers/img/404.png$ - [G,L]
66 # Block attempts to access old API versions
68 RewriteRule ^/api/0.[12345]/ - [G,L]
71 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
72 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
74 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
78 # Block a changeset that seems to lock things up
80 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
83 # Force special MIME type for crossdomain.xml files
85 <Files crossdomain.xml>
86 ForceType text/x-cross-domain-policy
90 # Set expiry for assets
93 Header unset Last-Modified
97 ExpiresDefault "access plus 1 year"
101 # Set expiry for attachments
103 <Location /attachments/>
104 Header unset Last-Modified
108 ExpiresDefault "access plus 1 year"
112 # Set expiry for other static content
114 <Location /export/embed.html>
115 ExpiresDefault "access plus 7 days"
118 ExpiresDefault "access plus 10 years"
120 <Location /javascripts/>
121 ExpiresDefault "access plus 10 years"
123 <Location /openlayers/>
124 ExpiresDefault "access plus 7 days"
126 <Location /stylesheets/>
127 ExpiresDefault "access plus 10 years"
131 # Set expiry for Potlatch 1
133 <Location /potlatch/>
134 ExpiresDefault "access plus 7 days"
138 # Set expiry for Potlatch 2
140 <Location /potlatch2/>
141 ExpiresByType application/x-shockwave-flash "access plus 1 day"
142 ExpiresByType application/xml "access plus 1 day"
143 ExpiresByType text/css "access plus 1 day"
144 ExpiresByType image/png "access plus 7 days"
150 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
152 PassengerMinInstances 10
153 PassengerMaxRequests 5000
154 PassengerMaxRequestQueueSize 250
155 PassengerPreStart https://www.openstreetmap.org/
156 PassengerAppGroupName rails
157 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
158 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
159 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
160 Alias /stats /store/rails/stats
161 Alias /user/image /store/rails/user/image
162 Alias /attachments /store/rails/attachments
165 # Preserve the host name when forwarding to the proxy
170 # Set a long timeout - changeset uploads can take a long time
175 # Allow all proxy requests
182 # Pass some other API calls to the backends via a load balancer
184 ProxyPass /api/0.6/map balancer://backend/api/0.6/map
185 ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
186 ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
187 ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
188 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+)$ balancer://backend$1
189 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload)$ balancer://ic$1
190 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download)$ balancer://backend$1
191 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
192 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
193 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
194 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
195 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
196 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
199 # Redirect trac and wiki requests to the right places
201 RedirectPermanent /trac/ https://trac.openstreetmap.org/
202 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
205 # Redirect requests for various images to the right place
207 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
208 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
211 # Define a load balancer for the local backends
213 <Proxy balancer://backend>
214 ProxySet lbmethod=bybusyness
215 <% node[:web][:backends].each do |backend| -%>
216 BalancerMember https://<%= backend %> disablereuse=on
221 # Define a load balancer for the IC backends
223 <Proxy balancer://ic>
224 ProxySet lbmethod=bybusyness
225 <% ["rails1.ic", "rails2.ic", "rails3.ic"].each do |backend| -%>
226 BalancerMember https://<%= backend %> disablereuse=on
231 # Redirect api requests made to www.osm.org to api.osm.org
233 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
234 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
237 # Redirect non-api requests made to api.osm.org to www.osm.org
239 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
240 RewriteCond %{REQUEST_URI} !^/api/
241 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
245 ServerName openstreetmap.org.uk
246 ServerAlias www.openstreetmap.org.uk
247 ServerAlias openstreetmap.co.uk
248 ServerAlias www.openstreetmap.co.uk
250 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
251 RedirectPermanent / https://www.openstreetmap.org/
255 ServerName openstreetmap.org
260 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
262 RewriteCond %{REQUEST_URI} !^/server-status$
263 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
267 ServerName openstreetmap.org
271 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
272 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
274 RedirectPermanent / https://www.openstreetmap.org/
277 <Directory <%= node[:web][:base_directory] %>/rails/public>
281 <Directory /srv/www.openstreetmap.org/rails/app/assets>
285 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
289 <Directory /store/rails/stats>
293 <Directory /store/rails/user/image>
297 <Directory /store/rails/attachments>