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
15 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
16 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
21 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
22 CustomLog /var/log/apache2/access.log combined_with_time
23 ErrorLog /var/log/apache2/error.log
26 # Turn on various features
32 # Add the unique ID to the request headers
34 RequestHeader set X-Request-Id %{UNIQUE_ID}e
37 # Remove Proxy request header to mitigate https://httpoxy.org/
39 RequestHeader unset Proxy early
42 # Block troublesome GPX data scrapping
44 RewriteCond %{REQUEST_METHOD} HEAD
45 RewriteRule ^/trace/\d+/data - [F,L]
50 RewriteCond %{HTTP_USER_AGENT} tilesAtHome
54 # Block changeset scraper
56 RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
60 # Block attempts to access old API versions
62 RewriteRule ^/api/0.[12345]/ - [G,L]
65 # Block JOSM revisions 1722-1727 as they have a serious bug that causes
66 # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
68 RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
72 # Block a changeset that seems to lock things up
74 RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
77 # Force special MIME type for crossdomain.xml files
79 <Files crossdomain.xml>
80 ForceType text/x-cross-domain-policy
84 # Set expiry for assets
87 Header unset Last-Modified
90 ExpiresDefault "access plus 1 year"
91 Header set Cache-Control "immutable, max-age=31536000"
95 # Set expiry for attachments
97 <Location /attachments/>
101 ExpiresDefault "access plus 1 year"
105 # Set expiry for other static content
107 <Location /export/embed.html>
108 ExpiresDefault "access plus 7 days"
111 ExpiresDefault "access plus 10 years"
113 <Location /openlayers/>
114 Header unset Last-Modified
117 Header always set Cache-Control "public, max-age=31536000, immutable"
118 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
124 DocumentRoot <%= node[:web][:base_directory] %>/rails/public
126 PassengerMinInstances 10
127 PassengerMaxRequests 5000
128 PassengerMaxRequestQueueSize 250
129 PassengerPreStart https://www.openstreetmap.org/
130 PassengerAppGroupName rails
131 SetEnv OPENSTREETMAP_STATUS <%= @status %>
132 SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
133 Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
134 Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
135 Alias /stats /store/rails/stats
136 Alias /user/image /store/rails/user/image
137 Alias /attachments /store/rails/attachments
140 # Pass authentication related headers to cgimap
147 # Pass supported calls to cgimap
149 RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
150 RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
151 RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
152 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
153 RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
154 RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
155 RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
156 RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
157 RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ fcgi://127.0.0.1:8000$0 [P]
160 # Redirect trac and wiki requests to the right places
162 RedirectPermanent /trac/ https://trac.openstreetmap.org/
163 RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
166 # Redirect requests for various images to the right place
168 RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
169 RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
172 # Redirect api requests made to www.osm.org to api.osm.org
174 # RewriteCond %{HTTP_HOST} =www.openstreetmap.org
175 # RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
178 # Redirect non-api requests made to api.osm.org to www.osm.org
180 RewriteCond %{HTTP_HOST} =api.openstreetmap.org
181 RewriteCond %{REQUEST_URI} !^/api/
182 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
186 ServerName openstreetmap.org.uk
187 ServerAlias www.openstreetmap.org.uk
188 ServerAlias openstreetmap.co.uk
189 ServerAlias www.openstreetmap.co.uk
191 RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
192 RedirectPermanent / https://www.openstreetmap.org/
196 ServerName openstreetmap.org
198 Header always set Cache-Control "max-age=31536000"
199 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
203 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
205 RewriteCond %{REQUEST_URI} !^/server-status$
206 RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
210 ServerName www.openstreetmap.org
213 Header always set Cache-Control "max-age=31536000"
214 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
218 RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
220 RewriteCond %{REQUEST_URI} !^/server-status$
221 RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
225 ServerName openstreetmap.org
229 SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
230 SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
232 Header always set Cache-Control "max-age=31536000"
233 Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
235 RedirectPermanent / https://www.openstreetmap.org/
238 <Directory <%= node[:web][:base_directory] %>/rails/public>
241 RewriteCond "%{HTTP:Accept-encoding}" "gzip"
242 RewriteCond "%{REQUEST_FILENAME}\.gz" -s
243 RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
245 RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1]
246 RewriteRule "\.ico\.gz$" "-" [T=image/vnd.microsoft.icon,E=no-gzip:1]
247 RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
248 RewriteRule "\.json\.gz$" "-" [T=application/json,E=no-gzip:1]
249 RewriteRule "\.svg\.gz$" "-" [T=image/svg+xml,E=no-gzip:1]
250 RewriteRule "\.xml\.gz$" "-" [T=application/xml,E=no-gzip:1]
252 <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
253 Header append Content-Encoding gzip
254 Header append Vary Accept-Encoding
258 <Directory /srv/www.openstreetmap.org/static>
262 <Directory /srv/www.openstreetmap.org/rails/app/assets>
266 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
270 <Directory /store/rails/stats>
274 <Directory /store/rails/user/image>
278 <Directory /store/rails/attachments>