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