]> git.openstreetmap.org Git - chef.git/blob - cookbooks/tile/templates/default/apache.erb
Use volume for nested podman container storage
[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   # Set location of renderd socket
23   ModTileRenderdSocketName /run/renderd/renderd.sock
24
25   # Set location of tile directory
26   ModTileTileDir /srv/tile.openstreetmap.org/tiles
27
28   # Time to wait for a re-render before serving a dirty tile
29   ModTileRequestTimeout 2
30
31   # Timeout before giving up for a tile to be rendered that is otherwise missing
32   ModTileMissingRequestTimeout 10
33
34   # Always try and re-render dirty or missing tiles
35   ModTileMaxLoadOld 1000
36   ModTileMaxLoadMissing 1000
37
38   # Maximum expiry to set on a tile
39   ModTileCacheDurationMax 604800
40
41   # Expiry time for dirty tiles that have been queued for re-rendering
42   ModTileCacheDurationDirty 900
43
44   # Minimum expiry time for fresh tiles
45   ModTileCacheDurationMinimum 10800
46   ModTileCacheDurationMediumZoom 13 86400
47   ModTileCacheDurationLowZoom 9 518400
48
49   # Factor controlling effect of last modification time on expiry
50   ModTileCacheLastModifiedFactor 0.20
51
52   # Load tile configuration
53   LoadTileConfigFile /etc/renderd.conf
54
55   # Get the real remote IP for requests via a trusted proxy
56   RemoteIPHeader Fastly-Client-IP
57 <% @fastly.sort.each do |address| -%>
58   RemoteIPTrustedProxy <%= address %>
59 <% end -%>
60
61   # Setup logging
62   LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Dus \"%{client-geo-continent}i\" \"%{client-geo-country}i\" \"%{client-geo-proxy-description}i\" \"%{client-geo-proxy-type}i\" \"%{client-geo-conn-type}i\" \"%{cdn-region}i\" \"%{cdn-pop}i\" \"%{X-TLS-JA4}i\" \"%{X-JA4H}i\""  combined_fastly_tile_custom
63   CustomLog /var/log/apache2/access.log combined_fastly_tile_custom
64   ErrorLog /var/log/apache2/error.log
65
66   # Always set Access-Control-Allow-Origin so that simple CORS requests
67   # will always work and can be cached
68   Header always set Access-Control-Allow-Origin "*" "expr=-z resp('Access-Control-Allow-Origin')"
69   Header always set Access-Control-Allow-Methods "GET, HEAD, OPTIONS" "expr=-z resp('Access-Control-Allow-Methods')"
70   Header always set Access-Control-Allow-Headers "X-Requested-With" "expr=-z resp('Access-Control-Allow-Headers')"
71
72   # Add diagnostics header to identify render server
73   Header always set X-TileRender "<%= node.name %>"
74
75   # Tell clients to use stale tiles if necessary
76   Header append Cache-Control "stale-while-revalidate=604800, stale-if-error=604800" "expr=%{CONTENT_TYPE} == 'image/png'"
77
78   # Remove Proxy request header to mitigate https://httpoxy.org/
79   RequestHeader unset Proxy early
80
81   # Enable the rewrite engine
82   RewriteEngine on
83
84   # Rewrite tile requests to the default style
85   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png$ /default/$1/$2/$3.png [PT,T=image/png,L]
86   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/status/?$  /default/$1/$2/$3.png/status [PT,T=text/plain,L]
87   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/dirty/?$   /default/$1/$2/$3.png/dirty  [PT,T=text/plain,L]
88
89   # Historical Files redirect
90   RedirectPermanent /processed_p.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
91   RedirectPermanent /shoreline_300.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
92   RedirectPermanent /world_boundaries-spherical.tgz https://planet.openstreetmap.org/historical-shapefiles/
93
94   # Redirect ACME certificate challenges
95   RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
96
97   # Restrict tile access to CDN nodes and admins
98   <LocationMatch ^/default/\d+/\d+/\d+\.png$>
99     Require expr "%{CONN_REMOTE_ADDR} != %{REMOTE_ADDR}"
100     # Fastly POPs
101 <% @fastly.sort.each do |address| -%>
102     Require ip <%= address %>
103 <% end -%>
104     # StatusCake monitoring
105 <% @statuscake.sort.reject { |address| address.empty? }.each do |address| -%>
106     Require ip <%= address %>
107 <% end -%>
108     # Administrators
109 <% @admins.sort.each do |address| -%>
110     Require ip <%= address %>
111 <% end -%>
112     # OSM Amsterdam IPv4 (he.net)
113     Require ip 184.104.179.128/27
114     # OSM Amsterdam IPv4 (equinix)
115     Require ip 82.199.86.96/27
116     # OSM Amsterdam IPv6 (he.net)
117     Require ip 2001:470:1:fa1::/64
118     # OSM Amsterdam IPv6 (equinix)
119     Require ip 2001:4d78:500:5e3::/64
120     # OSM Dublin IPv4 (he.net)
121     Require ip 184.104.226.96/27
122     # OSM Dublin IPv4 (equinix)
123     Require ip 87.252.214.96/27
124     # OSM Dublin IPv6 (he.net)
125     Require ip 2001:470:1:b3b::/64
126     # OSM Dublin IPv6 (equinix)
127     Require ip 2001:4d78:fe03:1c::/64
128     # OSM UCL IPv4
129     Require ip 193.60.236.0/24
130   </LocationMatch>
131 </VirtualHost>
132
133 <VirtualHost *:80>
134   # Basic server configuration
135   ServerName <%= node.name %>
136   ServerAlias tile.openstreetmap.org
137   ServerAlias render.openstreetmap.org
138   ServerAdmin webmaster@openstreetmap.org
139
140   # Setup logging
141   LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_with_remoteip
142   CustomLog /var/log/apache2/access.log combined_with_remoteip
143   ErrorLog /var/log/apache2/error.log
144
145   # Always set Access-Control-Allow-Origin so that simple CORS requests
146   # will always work and can be cached
147   Header always set Access-Control-Allow-Origin "*"
148   Header always set Access-Control-Allow-Methods "GET, HEAD, OPTIONS"
149   Header always set Access-Control-Allow-Headers "X-Requested-With"
150
151   # Add diagnostics header to identify render server
152   Header set X-TileRender "<%= node.name %>"
153
154   # Remove Proxy request header to mitigate https://httpoxy.org/
155   RequestHeader unset Proxy early
156
157   # Enable the rewrite engine
158   RewriteEngine on
159
160   # Redirect ACME certificate challenges
161   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
162
163   # Redirect to https
164   RewriteCond %{REQUEST_URI} !^/server-status$
165   RewriteCond %{REQUEST_URI} !^/mod_tile$
166   RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=permanent,L]
167 </VirtualHost>
168
169 <Directory /srv/tile.openstreetmap.org/html>
170   Options None
171   AllowOverride None
172   Require all granted
173 </Directory>
174
175 <Directory /srv/tile.openstreetmap.org/cgi-bin>
176   Options ExecCGI
177   AllowOverride None
178   Require all granted
179 </Directory>