2 # DO NOT EDIT - This file is being maintained by Chef
3 location ~* "^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" {
6 rewrite ^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.jpg /mosaicjson/tiles/WebMercatorQuad/$1/$2/$3@1x?url=<%= URI.encode_www_form_component(@source) %>&pixel_selection=first&tile_format=jpeg break;
7 rewrite ^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.jpeg /mosaicjson/tiles/WebMercatorQuad/$1/$2/$3@1x?url=<%= URI.encode_www_form_component(@source) %>&pixel_selection=first&tile_format=jpeg break;
8 rewrite ^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.png /mosaicjson/tiles/WebMercatorQuad/$1/$2/$3@1x?url=<%= URI.encode_www_form_component(@source) %>&pixel_selection=first&tile_format=png break;
9 proxy_pass http://tiler_backend;
10 proxy_set_header Host $host;
11 proxy_set_header Referer $http_referer;
12 proxy_set_header X-Forwarded-For $remote_addr;
13 proxy_set_header X-Forwarded-Proto https;
14 proxy_set_header X-Forwarded-SSL on;
15 proxy_http_version 1.1;
16 proxy_set_header Connection "";
17 proxy_set_header Cache-Control "";
18 proxy_set_header Pragma "";
20 proxy_cache_key "<%= @layer %><%= @revision %> $request_method $1 $2 $3";
21 proxy_cache proxy_cache_zone;
22 proxy_cache_valid 200 204 180d;
23 proxy_cache_use_stale error timeout updating http_502 http_503 http_504;
24 proxy_cache_background_update on;
25 proxy_next_upstream error timeout invalid_header http_500 http_503;
26 proxy_next_upstream_tries 3;
27 proxy_intercept_errors on;
28 proxy_next_upstream_timeout 30s;
31 # Override QUERY_STRING to force mapserver query parameters
32 fastcgi_param QUERY_STRING "map=/srv/imagery/mapserver/layer-<%= @layer %>.map&mode=tile&layers=<%= @layer %>&tilemode=gmap&tile=$2+$3+$1";
33 fastcgi_pass "<%= @site %>_fastcgi";
34 include fastcgi_params;
35 fastcgi_param REQUEST_METHOD "GET";
36 fastcgi_param HTTP_PROXY "";
37 fastcgi_read_timeout 60s;
40 fastcgi_cache "fastcgi_cache_zone";
41 fastcgi_cache_key "<%= @layer %><%= @revision %> $request_method $1 $2 $3";
43 # Free connection to socket for other requests
44 fastcgi_keep_conn off;
46 fastcgi_cache_valid 200 21d;
48 # Serve stale cache on errors or if updating
49 fastcgi_cache_use_stale error timeout updating http_500 http_503;
50 # If in cache as stale, serve stale and update in background
51 fastcgi_cache_background_update on;
52 # Enable revalidation using If-Modified-Since and If-None-Match for stale items
53 fastcgi_cache_revalidate on;
57 fastcgi_catch_stderr "Image handling error";
59 fastcgi_next_upstream error timeout invalid_header http_500 http_503;
60 fastcgi_next_upstream_tries 8;
66 # Add HTTP Cache-Control + Expires Headers
68 add_header Cache-Control "stale-while-revalidate=604800, stale-if-error=604800";
69 add_header x-cache-status $upstream_cache_status;
72 add_header 'Access-Control-Allow-Origin' '*';
76 rewrite "^/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" "/layer/<%= @layer %>/$1/$2/$3.$4" last;
78 <% @url_aliases.each do |url| -%>
79 rewrite "^<%= url %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" "/layer/<%= @layer %>/$1/$2/$3.$4" last;