]> git.openstreetmap.org Git - chef.git/blob - cookbooks/web/templates/default/apache.frontend.erb
account: update ligfietser ssh key
[chef.git] / cookbooks / web / templates / default / apache.frontend.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 #
4 # Setup logging
5
6 SetEnvIfNoCase Authorization "^Basic " AUTH_METHOD=basic
7 SetEnvIfNoCase Authorization "^OAuth " AUTH_METHOD=oauth1
8 SetEnvIfNoCase Authorization "^Bearer " AUTH_METHOD=oauth2
9 SetEnvIfExpr "%{QUERY_STRING} =~ /(^|&)oauth_signature=/" AUTH_METHOD=oauth1
10 LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Dus %{UNIQUE_ID}e %{SSL_PROTOCOL}x %{SSL_CIPHER}x %{AUTH_METHOD}e" combined_with_time
11 CustomLog /var/log/apache2/access.log combined_with_time
12 ErrorLog /var/log/apache2/error.log
13
14 <VirtualHost *:443>
15   #
16   # Basic server configuration
17   #
18   ServerName <%= node[:fqdn] %>
19   ServerAlias api.openstreetmap.org www.openstreetmap.org 127.0.0.1
20   ServerAdmin webmaster@openstreetmap.org
21
22   #
23   # Enable SSL
24   #
25   SSLEngine on
26   SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
27   SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
28
29   #
30   # Turn on various features
31   #
32   ExpiresActive On
33   RewriteEngine on
34
35   #
36   # Configure timeouts
37   #
38   TimeOut 10
39   RequestReadTimeout handshake=10-20,MinRate=500 header=10-20,MinRate=500 body=10-120,MinRate=500
40   LogLevel reqtimeout:info
41
42   #
43   # Add the unique ID to the request headers
44   #
45   RequestHeader set X-Request-Id %{UNIQUE_ID}e
46
47   #
48   # Remove Proxy request header to mitigate https://httpoxy.org/
49   #
50   RequestHeader unset Proxy early
51
52   #
53   # Block troublesome GPX data scrapping
54   #
55   RewriteCond %{REQUEST_METHOD} HEAD
56   RewriteRule ^/trace/\d+/data - [F,L]
57
58   #
59   # Block tilesAtHome
60   #
61   RewriteCond %{HTTP_USER_AGENT} tilesAtHome
62   RewriteRule . - [F,L]
63
64   #
65   # Block changeset scraper
66   #
67   RewriteCond %{HTTP_USER_AGENT} "OSMApp Tuner"
68   RewriteRule . - [F,L]
69
70   #
71   # Block trace scraper
72   #
73   RewriteCond %{HTTP_USER_AGENT} "python-httpx/0.24.1"
74   RewriteRule . - [F,L]
75
76   #
77   # Block out of control spider
78   #
79   RewriteCond %{HTTP_USER_AGENT} "Bytespider"
80   RewriteRule . - [F,L]
81
82   #
83   # Block attempts to access old API versions
84   #
85   RewriteRule ^/api/0.[12345]/ - [G,L]
86
87   #
88   # Block JOSM revisions  1722-1727 as they have a serious bug that causes
89   # lat/lon to be swapped (https://josm.openstreetmap.de/ticket/2804)
90   #
91   RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
92   RewriteRule . - [F,L]
93
94   #
95   # Block a changeset that seems to lock things up
96   #
97   RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
98
99   #
100   # Ignore Vicon Valerus "online" status pings
101   # https://gist.github.com/Firefishy/86ed5b86991b225179b54bbafbcd769e
102   #
103   RewriteCond "%{QUERY_STRING}" "^q=abcde&t=20"
104   RewriteRule "^/api/0\.6/notes/search$" - [R=429,L]
105
106   #
107   # Force special MIME type for crossdomain.xml files
108   #
109   <Files crossdomain.xml>
110     ForceType text/x-cross-domain-policy
111   </Files>
112
113   #
114   # Set expiry for assets
115   #
116   <Location /assets/>
117     Header unset Last-Modified
118     FileETag Size
119
120     ExpiresDefault "access plus 1 year"
121     Header set Cache-Control "immutable, max-age=31536000"
122   </Location>
123
124   #
125   # Set expiry for attachments
126   #
127   <Location /attachments/>
128     Header unset ETag
129     FileETag None
130
131     ExpiresDefault "access plus 1 year"
132   </Location>
133
134   #
135   # Set expiry for other static content
136   #
137   <Location /export/embed.html>
138     ExpiresDefault "access plus 7 days"
139   </Location>
140   <Location /images/>
141     ExpiresDefault "access plus 10 years"
142   </Location>
143   <Location /openlayers/>
144     Header unset Last-Modified
145     FileETag Size
146
147     Header always set Cache-Control "public, max-age=31536000, immutable"
148     Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
149   </Location>
150
151   #
152   # Configure rails
153   #
154   DocumentRoot <%= node[:web][:base_directory] %>/rails/public
155   RailsEnv production
156   PassengerMinInstances 10
157   PassengerMaxRequests 5000
158   PassengerMaxRequestQueueSize 250
159   PassengerPreStart https://www.openstreetmap.org/
160   PassengerAppGroupName rails
161   SetEnv OPENSTREETMAP_STATUS <%= @status %>
162   SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
163   Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/favicons/favicon.ico
164   Alias /openlayers <%= node[:web][:base_directory] %>/static/openlayers
165   RedirectPermanent /stats https://planet.openstreetmap.org/statistics
166
167   #
168   # Pass authentication related headers to cgimap
169   #
170   <Location />
171     CGIPassAuth On
172   </Location>
173
174   #
175   # Pass supported calls to cgimap
176   #
177   RewriteRule ^/api/0\.6/map(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
178   RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
179   RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
180   RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/history(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
181   RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+/relations(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
182   RewriteRule ^/api/0\.6/node/[0-9]+/ways(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
183   RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
184   RewriteRule ^/api/0\.6/(nodes|ways|relations)(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
185   RewriteRule ^/api/0\.6/changeset/[0-9]+/(upload|download)(\.json|\.xml)?$ unix:/run/cgimap/socket|fcgi://127.0.0.1$0 [P]
186
187   #
188   # Redirect trac and wiki requests to the right places
189   #
190   RedirectPermanent /trac/ https://trac.openstreetmap.org/
191   RedirectPermanent /wiki/ https://wiki.openstreetmap.org/
192
193   #
194   # Redirect requests for various images to the right place
195   #
196   RedirectPermanent /images/osm_logo.png https://www.openstreetmap.org/assets/osm_logo.png
197   RedirectPermanent /images/cc_button.png https://www.openstreetmap.org/assets/cc_button.png
198
199   #
200   # Redirect api requests made to www.openstreetmap.org to api.openstreetmap.org
201   #
202 #  RewriteCond %{HTTP_HOST} =www.openstreetmap.org
203 #  RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
204
205   #
206   # Redirect non-api requests made to api.openstreetmap.org to www.openstreetmap.org
207   #
208   RewriteCond %{HTTP_HOST} =api.openstreetmap.org
209   RewriteCond %{REQUEST_URI} !^/api/
210   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
211 </VirtualHost>
212
213 <VirtualHost *:80>
214   ServerName openstreetmap.org.uk
215   ServerAlias www.openstreetmap.org.uk
216   ServerAlias openstreetmap.co.uk
217   ServerAlias www.openstreetmap.co.uk
218
219   RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
220   RedirectPermanent / https://www.openstreetmap.org/
221 </VirtualHost>
222
223 <VirtualHost *:80>
224   ServerName osm.org
225
226   Header always set Cache-Control "max-age=31536000"
227   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
228
229   RewriteEngine on
230
231   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
232
233   RewriteCond %{REQUEST_URI} !^/server-status$
234   RewriteRule ^(.*)$ https://osm.org$1 [L,NE,R=permanent]
235 </VirtualHost>
236
237 <VirtualHost *:80>
238   ServerName www.osm.org
239
240   Header always set Cache-Control "max-age=31536000"
241   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
242
243   RewriteEngine on
244
245   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
246
247   RewriteCond %{REQUEST_URI} !^/server-status$
248   RewriteRule ^(.*)$ https://www.osm.org$1 [L,NE,R=permanent]
249 </VirtualHost>
250
251 <VirtualHost *:80>
252   ServerName openstreetmap.org
253
254   Header always set Cache-Control "max-age=31536000"
255   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
256
257   RewriteEngine on
258
259   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
260
261   RewriteCond %{REQUEST_URI} !^/server-status$
262   RewriteRule ^(.*)$ https://openstreetmap.org$1 [L,NE,R=permanent]
263 </VirtualHost>
264
265 <VirtualHost *:80>
266   ServerName www.openstreetmap.org
267   ServerAlias *
268
269   Header always set Cache-Control "max-age=31536000"
270   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
271
272   RewriteEngine on
273
274   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
275
276   RewriteCond %{REQUEST_URI} !^/server-status$
277   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
278 </VirtualHost>
279
280 <VirtualHost *:443>
281   ServerName openstreetmap.org
282   ServerAlias *
283
284   SSLEngine on
285   SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
286   SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
287
288   Header always set Cache-Control "max-age=31536000"
289   Header always set Expires "Tue, 19 Jan 2038 03:14:07 GMT"
290
291   RedirectPermanent / https://www.openstreetmap.org/
292 </VirtualHost>
293
294 <Directory <%= node[:web][:base_directory] %>/rails/public>
295   Require all granted
296
297   RewriteCond "%{HTTP:Accept-encoding}" "br"
298   RewriteCond "%{REQUEST_FILENAME}\.br" -s
299   RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.br" [QSA]
300
301   RewriteCond "%{HTTP:Accept-encoding}" "gzip"
302   RewriteCond "%{REQUEST_FILENAME}\.gz" -s
303   RewriteRule "^(.*)\.(css|ico|js|json|svg|xml)$" "$1\.$2\.gz" [QSA]
304
305   RewriteRule "\.css\.(br|gz)$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
306   RewriteRule "\.ico\.(br|gz)$"  "-" [T=image/vnd.microsoft.icon,E=no-gzip:1,E=no-brotli:1]
307   RewriteRule "\.js\.(br|gz)$"  "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
308   RewriteRule "\.json\.(br|gz)$"  "-" [T=application/json,E=no-gzip:1,E=no-brotli:1]
309   RewriteRule "\.svg\.(br|gz)$"  "-" [T=image/svg+xml,E=no-gzip:1,E=no-brotli:1]
310   RewriteRule "\.xml\.(br|gz)$"  "-" [T=application/xml,E=no-gzip:1,E=no-brotli:1]
311
312   <FilesMatch "\.(css|ico|js|json|svg|xml)\.br$">
313     Header append Content-Encoding br
314     Header append Vary Accept-Encoding
315   </FilesMatch>
316
317   <FilesMatch "\.(css|ico|js|json|svg|xml)\.gz$">
318     Header append Content-Encoding gzip
319     Header append Vary Accept-Encoding
320   </FilesMatch>
321 </Directory>
322
323 <Directory /srv/www.openstreetmap.org/static>
324   Require all granted
325 </Directory>
326
327 <Directory /srv/www.openstreetmap.org/rails/app/assets>
328   Require all granted
329 </Directory>
330
331 <Directory /srv/www.openstreetmap.org/rails/vendor/assets>
332   Require all granted
333 </Directory>