]> git.openstreetmap.org Git - chef.git/blob - cookbooks/tile/templates/default/apache.erb
nominatim: install secondary importance file
[chef.git] / cookbooks / tile / templates / default / apache.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 <VirtualHost *:443>
4   # Basic server configuration
5   ServerName <%= node.name %>
6   ServerAlias tile.openstreetmap.org
7   ServerAlias render.openstreetmap.org
8   ServerAdmin webmaster@openstreetmap.org
9
10   #
11   # Enable SSL
12   #
13   SSLEngine on
14   SSLProxyEngine on
15   SSLCertificateFile /etc/ssl/certs/<%= node[:fqdn] %>.pem
16   SSLCertificateKeyFile /etc/ssl/private/<%= node[:fqdn] %>.key
17
18   # Configure location of static files and CGI scripts
19   DocumentRoot /srv/tile.openstreetmap.org/html
20   ScriptAlias /cgi-bin/ /srv/tile.openstreetmap.org/cgi-bin/
21
22   # Get the real remote IP for requests via a trusted proxy
23   RemoteIPHeader Fastly-Client-IP
24 <% @fastly.sort.each do |address| -%>
25   RemoteIPTrustedProxy <%= address %>
26 <% end -%>
27
28   # Setup logging
29   LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_with_remoteip
30   CustomLog /var/log/apache2/access.log combined_with_remoteip
31   ErrorLog /var/log/apache2/error.log
32   BufferedLogs on
33
34   # Always set Access-Control-Allow-Origin so that simple CORS requests
35   # will always work and can be cached
36   Header set Access-Control-Allow-Origin "*"
37
38   # Add diagnostics header to identify render server
39   Header set X-TileRender "<%= node.name %>"
40
41   # Tell clients to use stale tiles if necessary
42   Header append Cache-Control "stale-while-revalidate=604800, stale-if-error=604800" "expr=%{CONTENT_TYPE} == 'image/png'"
43
44   # Remove Proxy request header to mitigate https://httpoxy.org/
45   RequestHeader unset Proxy early
46
47   # Enable the rewrite engine
48   RewriteEngine on
49
50   # Rewrite tile requests to the default style
51   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png$ /default/$1/$2/$3.png [PT,T=image/png,L]
52   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/status/?$  /default/$1/$2/$3.png/status [PT,T=text/plain,L]
53   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/dirty/?$   /default/$1/$2/$3.png/dirty  [PT,T=text/plain,L]
54
55   # Historical Files redirect
56   RedirectPermanent /processed_p.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
57   RedirectPermanent /shoreline_300.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
58   RedirectPermanent /world_boundaries-spherical.tgz https://planet.openstreetmap.org/historical-shapefiles/
59
60   # Redirect ACME certificate challenges
61   RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
62
63   # Restrict tile access to CDN nodes and admins
64   <LocationMatch ^/default/\d+/\d+/\d+\.png$>
65     Require expr "%{CONN_REMOTE_ADDR} != %{REMOTE_ADDR}"
66     # Fastly POPs
67 <% @fastly.sort.each do |address| -%>
68     Require ip <%= address %>
69 <% end -%>
70     # StatusCake monitoring
71 <% @statuscake.sort.reject { |address| address.empty? }.each do |address| -%>
72     Require ip <%= address %>
73 <% end -%>
74     # Administrators
75 <% @admins.sort.each do |address| -%>
76     Require ip <%= address %>
77 <% end -%>
78     # OSM Amsterdam IPv4
79     Require ip 184.104.179.128/27
80     # OSM Amsterdam IPv6
81     Require ip 2001:470:1:fa1::/64
82     # OSM Dublin IPv4
83     Require ip 184.104.226.96/27
84     # OSM Dublin IPv6
85     Require ip 2001:470:1:b3b::/64
86     # OSM UCL IPv4
87     Require ip 193.60.236.0/24
88   </LocationMatch>
89 </VirtualHost>
90
91 <VirtualHost *:80>
92   # Basic server configuration
93   ServerName <%= node.name %>
94   ServerAlias tile.openstreetmap.org
95   ServerAlias render.openstreetmap.org
96   ServerAdmin webmaster@openstreetmap.org
97
98   # Setup logging
99   LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_with_remoteip
100   CustomLog /var/log/apache2/access.log combined_with_remoteip
101   ErrorLog /var/log/apache2/error.log
102   BufferedLogs on
103
104   # Always set Access-Control-Allow-Origin so that simple CORS requests
105   # will always work and can be cached
106   Header set Access-Control-Allow-Origin "*"
107
108   # Add diagnostics header to identify render server
109   Header set X-TileRender "<%= node.name %>"
110
111   # Remove Proxy request header to mitigate https://httpoxy.org/
112   RequestHeader unset Proxy early
113
114   # Enable the rewrite engine
115   RewriteEngine on
116
117   # Redirect ACME certificate challenges
118   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
119
120   # Redirect to https
121   RewriteCond %{REQUEST_URI} !^/server-status$
122   RewriteCond %{REQUEST_URI} !^/mod_tile$
123   RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=permanent,L]
124 </VirtualHost>
125
126 <Directory /srv/tile.openstreetmap.org/html>
127   Options None
128   AllowOverride None
129   Require all granted
130 </Directory>
131
132 <Directory /srv/tile.openstreetmap.org/cgi-bin>
133   Options ExecCGI
134   AllowOverride None
135   Require all granted
136 </Directory>