]> git.openstreetmap.org Git - chef.git/blob - cookbooks/tile/templates/default/apache.erb
Merge pull request #331 from Tigerfell/tiles
[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 X-Forwarded-For
24 <% @caches.each do |cache| -%>
25 <% cache.ipaddresses(:role => :external).sort.each do |address| -%>
26   RemoteIPTrustedProxy <%= address %>
27 <% end -%>
28 <% end -%>
29
30   # Setup logging
31   LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_with_remoteip
32   CustomLog /var/log/apache2/access.log combined_with_remoteip
33   ErrorLog /var/log/apache2/error.log
34   BufferedLogs on
35
36   # Always set Access-Control-Allow-Origin so that simple CORS requests
37   # will always work and can be cached
38   Header set Access-Control-Allow-Origin "*"
39
40   # Add diagnostics header to identify render server
41   Header set X-TileRender "<%= node.name %>"
42
43   # Tell clients to use stale tiles if necessary
44   Header append Cache-Control "stale-while-revalidate=604800, stale-if-error=604800" "expr=%{CONTENT_TYPE} == 'image/png'"
45
46   # Remove Proxy request header to mitigate https://httpoxy.org/
47   RequestHeader unset Proxy early
48
49   # Enable the rewrite engine
50   RewriteEngine on
51
52   # Rewrite tile requests to the default style
53   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png$ /default/$1/$2/$3.png [PT,T=image/png,L]
54   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/status/?$  /default/$1/$2/$3.png/status [PT,T=text/plain,L]
55   RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/dirty/?$   /default/$1/$2/$3.png/dirty  [PT,T=text/plain,L]
56
57   # Historical Files redirect
58   RedirectPermanent /processed_p.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
59   RedirectPermanent /shoreline_300.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
60   RedirectPermanent /world_boundaries-spherical.tgz https://planet.openstreetmap.org/historical-shapefiles/
61
62   # Redirect ACME certificate challenges
63   RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
64 </VirtualHost>
65
66 <VirtualHost *:80>
67   # Basic server configuration
68   ServerName <%= node.name %>
69   ServerAlias tile.openstreetmap.org
70   ServerAlias render.openstreetmap.org
71   ServerAdmin webmaster@openstreetmap.org
72
73   # Get the real remote IP for requests via a trusted proxy
74   RemoteIPHeader X-Forwarded-For
75 <% @caches.each do |cache| -%>
76 <% cache.ipaddresses(:role => :external).sort.each do |address| -%>
77   RemoteIPTrustedProxy <%= address %>
78 <% end -%>
79 <% end -%>
80
81   # Setup logging
82   LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined_with_remoteip
83   CustomLog /var/log/apache2/access.log combined_with_remoteip
84   ErrorLog /var/log/apache2/error.log
85   BufferedLogs on
86
87   # Always set Access-Control-Allow-Origin so that simple CORS requests
88   # will always work and can be cached
89   Header set Access-Control-Allow-Origin "*"
90
91   # Add diagnostics header to identify render server
92   Header set X-TileRender "<%= node.name %>"
93
94   # Remove Proxy request header to mitigate https://httpoxy.org/
95   RequestHeader unset Proxy early
96
97   # Enable the rewrite engine
98   RewriteEngine on
99
100   # Redirect ACME certificate challenges
101   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
102
103   # Redirect to https
104   RewriteCond %{REQUEST_URI} !^/server-status$
105   RewriteCond %{REQUEST_URI} !^/mod_tile$
106   RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=permanent,L]
107 </VirtualHost>
108
109 <Directory /srv/tile.openstreetmap.org/html>
110   Options None
111   AllowOverride None
112   Require all granted
113 </Directory>
114
115 <Directory /srv/tile.openstreetmap.org/cgi-bin>
116   Options ExecCGI
117   AllowOverride None
118   Require all granted
119 </Directory>