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 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
157 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
158 Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
159 Alias /stats /store/rails/stats
160 Alias /user/image /store/rails/user/image
161 Alias /attachments /store/rails/attachments
164 # Preserve the host name when forwarding to the proxy
169 # Set a long timeout - changeset uploads can take a long time
174 # Allow all proxy requests
181 # Pass some other API calls to the backends via a load balancer
183 ProxyPass /api/0.6/map balancer://backend/api/0.6/map
184 ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
185 ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
186 ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
187 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+)$ balancer://backend$1
188 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/upload)$ balancer://ic$1
189 ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/download)$ balancer://backend$1
190 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
191 ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
192 ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
193 ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
194 ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
195 ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
198 # Redirect trac and wiki requests to the right places
200 RedirectPermanent /trac/ https://trac.openstreetmap.org/
201 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
204 # Redirect requests for various images to the right place
206 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
207 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
210 # Define a load balancer for the local backends
212 <Proxy balancer://backend>
213 ProxySet lbmethod=bybusyness
214 <% node[:web][:backends].each do |backend| -%>
215 BalancerMember https://<%= backend %> disablereuse=on
220 # Define a load balancer for the IC backends
222 <Proxy balancer://ic>
223 ProxySet lbmethod=bybusyness
224 <% ["rails1.ic", "rails2.ic", "rails3.ic"].each do |backend| -%>
225 BalancerMember https://<%= backend %> disablereuse=on
230 # Redirect api requests made to www.osm.org to api.osm.org
232 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
233 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
236 # Redirect non-api requests made to api.osm.org to www.osm.org
238 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
239 RewriteCond %{REQUEST_URI} !^/api/
240 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
244 ServerName openstreetmap.org.uk
245 ServerAlias www.openstreetmap.org.uk
246 ServerAlias openstreetmap.co.uk
247 ServerAlias www.openstreetmap.co.uk
249 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
250 RedirectPermanent / https://www.openstreetmap.org/
254 ServerName openstreetmap.org
259 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
261 RewriteCond %{REQUEST_URI} !^/server-status$
262 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
266 ServerName openstreetmap.org
270 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
271 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
273 RedirectPermanent / https://www.openstreetmap.org/
276 <Directory <%= node[:web][:base_directory] %>/rails/public>
280 <Directory /srv/www.openstreetmap.org/rails/app/assets>
284 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
288 <Directory /store/rails/stats>
292 <Directory /store/rails/user/image>
296 <Directory /store/rails/attachments>