]> git.openstreetmap.org Git - chef.git/blob - cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb
f9caaea4de234b72ef3de18dfd56dfa4398805bc
[chef.git] / cookbooks / imagery / templates / default / nginx_imagery_layer_fragment.conf.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2 location ~* "^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" {
3   # Override QUERY_STRING to force mapserver query parameters
4   fastcgi_param QUERY_STRING "map=/srv/imagery/mapserver/layer-<%= @layer %>.map&mode=tile&layers=<%= @layer %>&tilemode=gmap&tile=$2+$3+$1";
5   fastcgi_pass "<%= @site %>_fastcgi";
6   fastcgi_buffers 8 64k;
7   fastcgi_busy_buffers_size 64k;
8   include fastcgi_params;
9   fastcgi_param REQUEST_METHOD "GET";
10   fastcgi_param HTTP_PROXY "";
11   fastcgi_read_timeout 60s;
12
13   # Caching
14   fastcgi_cache "fastcgi_cache_zone";
15   fastcgi_cache_key "<%= @layer %><%= @revision %> $request_method $1 $2 $3";
16
17   # Free connection to socket for other requests
18   fastcgi_keep_conn off;
19
20   fastcgi_cache_lock on;
21   fastcgi_cache_valid 200 21d;
22
23   # Serve stale cache on errors or if updating
24   fastcgi_cache_use_stale error timeout updating http_500 http_503 http_504;
25   # If in cache as stale, serve stale and update in background
26   fastcgi_cache_background_update on;
27   # Enable revalidation using If-Modified-Since and If-None-Match for stale items
28   fastcgi_cache_revalidate on;
29
30   # Ignore client abort as it causes issues with the pipeline
31   fastcgi_ignore_client_abort on;
32
33   fastcgi_catch_stderr "Image handling error";
34
35   fastcgi_next_upstream error timeout invalid_header http_500 http_503;
36   fastcgi_next_upstream_tries 8;
37
38   # Do not GZIP tiles
39   gzip off;
40
41   # Add HTTP Cache-Control + Expires Headers
42   expires 7d;
43
44   # Allow CORS requests
45   add_header 'Access-Control-Allow-Origin' '*';
46 }
47
48 <% if @root_layer -%>
49 rewrite "^/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" "/layer/<%= @layer %>/$1/$2/$3.$4" last;
50 <% end -%>
51 <% @url_aliases.each do |url| -%>
52 rewrite "^<%= url %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" "/layer/<%= @layer %>/$1/$2/$3.$4" last;
53 <% end -%>