From: Grant Slater Date: Fri, 7 Sep 2018 01:26:19 +0000 (+0100) Subject: imagery: add backend retry upstream logic X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/fd1ce6eb4fdb7d6715ddf25a13e85ed2fd2a10cc imagery: add backend retry upstream logic --- diff --git a/cookbooks/imagery/templates/default/nginx_imagery.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb index ec8a7ca31..20e8d5642 100644 --- a/cookbooks/imagery/templates/default/nginx_imagery.conf.erb +++ b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb @@ -7,6 +7,11 @@ server { return 301 https://$host$request_uri; } +upstream <%= @name %>_fastcgi { + server "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket"; + server "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket"; +} + server { listen [::]:443 ssl; listen *:443 ssl; diff --git a/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb index 922ec7a96..b96a6719c 100644 --- a/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb +++ b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb @@ -1,9 +1,8 @@ # DO NOT EDIT - This file is being maintained by Chef - location ~* "^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" { # Override QUERY_STRING to force mapserver query parameters fastcgi_param QUERY_STRING "map=/srv/imagery/mapserver/layer-<%= @layer %>.map&mode=tile&layers=<%= @layer %>&tilemode=gmap&tile=$2+$3+$1"; - fastcgi_pass "unix:/var/run/mapserver-fastcgi/layer-<%= @site %>.socket"; + fastcgi_pass "<%= @site %>_fastcgi"; fastcgi_buffers 8 64k; include fastcgi_params; fastcgi_param REQUEST_METHOD "GET"; @@ -27,6 +26,7 @@ location ~* "^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" { fastcgi_catch_stderr "Image handling error"; + fastcgi_next_upstream error timeout invalid_header http_500 http_503; fastcgi_next_upstream_tries 3; # Do not GZIP tiles