]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/tile/templates/default/apache.erb
planet: Stop redirecting to ancient tile data files
[chef.git] / cookbooks / tile / templates / default / apache.erb
index ef4ee9f147e512665da88be25b7207055724e4ed..0e461b8d60c0d006a6edd6a02e222500e4afb62b 100644 (file)
@@ -2,7 +2,7 @@
 
 <VirtualHost *:443>
   # Basic server configuration
-  ServerName <%= node[:fqdn] %>
+  ServerName <%= node.name %>
   ServerAlias tile.openstreetmap.org
   ServerAlias render.openstreetmap.org
   ServerAdmin webmaster@openstreetmap.org
   # will always work and can be cached
   Header set Access-Control-Allow-Origin "*"
 
+  # Add diagnostics header to identify render server
+  Header set X-TileRender "<%= node.name %>"
+
+  # Tell clients to use stale tiles if necessary
+  Header append Cache-Control "stale-while-revalidate=604800, stale-if-error=604800" "expr=%{CONTENT_TYPE} == 'image/png'"
+
   # Remove Proxy request header to mitigate https://httpoxy.org/
   RequestHeader unset Proxy early
 
   RewriteEngine on
 
   # Rewrite tile requests to the default style
-  RewriteRule ^/(-?\d+)/(-?\d+)/(-?\d+)\.png$ /default/$1/$2/$3.png [PT,T=image/png,L]
-  RewriteRule ^/(-?\d+)/(-?\d+)/(-?\d+)\.png/status/?$  /default/$1/$2/$3.png/status [PT,T=text/plain,L]
-  RewriteRule ^/(-?\d+)/(-?\d+)/(-?\d+)\.png/dirty/?$   /default/$1/$2/$3.png/dirty  [PT,T=text/plain,L]
+  RewriteRule ^/(\d+)/(\d+)/(\d+)\.png$ /default/$1/$2/$3.png [PT,T=image/png,L]
+  RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/status/?$  /default/$1/$2/$3.png/status [PT,T=text/plain,L]
+  RewriteRule ^/(\d+)/(\d+)/(\d+)\.png/dirty/?$   /default/$1/$2/$3.png/dirty  [PT,T=text/plain,L]
 
   # Historical Files redirect
-  RedirectPermanent /processed_p.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/processed_p.tar.bz2
-  RedirectPermanent /shoreline_300.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/shoreline_300.tar.bz2
-  RedirectPermanent /world_boundaries-spherical.tgz https://planet.openstreetmap.org/historical-shapefiles/world_boundaries-spherical.tgz
+  RedirectPermanent /processed_p.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
+  RedirectPermanent /shoreline_300.tar.bz2 https://planet.openstreetmap.org/historical-shapefiles/
+  RedirectPermanent /world_boundaries-spherical.tgz https://planet.openstreetmap.org/historical-shapefiles/
 
   # Redirect ACME certificate challenges
   RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
@@ -59,7 +65,7 @@
 
 <VirtualHost *:80>
   # Basic server configuration
-  ServerName <%= node[:fqdn] %>
+  ServerName <%= node.name %>
   ServerAlias tile.openstreetmap.org
   ServerAlias render.openstreetmap.org
   ServerAdmin webmaster@openstreetmap.org
@@ -82,6 +88,9 @@
   # will always work and can be cached
   Header set Access-Control-Allow-Origin "*"
 
+  # Add diagnostics header to identify render server
+  Header set X-TileRender "<%= node.name %>"
+
   # Remove Proxy request header to mitigate https://httpoxy.org/
   RequestHeader unset Proxy early
 
   RewriteRule ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 [R=permanent,L]
 
   # Redirect to https
+  RewriteCond %{REQUEST_URI} !^/server-status$
+  RewriteCond %{REQUEST_URI} !^/mod_tile$
   RewriteRule (.*) https://%{SERVER_NAME}/$1 [R=permanent,L]
 </VirtualHost>