From: Grant Slater Date: Sun, 31 Jan 2016 15:22:36 +0000 (+0000) Subject: Imagery - nginx layer fragments X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/7a934ef4aaf32d97f15e62b253d3945baf9ea5bb Imagery - nginx layer fragments --- diff --git a/cookbooks/imagery/resources/layer.rb b/cookbooks/imagery/resources/layer.rb index dddd66522..648ac06d6 100644 --- a/cookbooks/imagery/resources/layer.rb +++ b/cookbooks/imagery/resources/layer.rb @@ -59,4 +59,43 @@ action :create do subscribes :restart, "template[/srv/imagery/mapserver/layer-#{name}.map]" subscribes :restart, "template[/etc/init/mapserv-fgi-layer-#{name}.conf]" end + + directory "/srv/imagery/nginx/#{site}" do + owner "root" + group "root" + mode 0755 + recursive true + end + + template "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do + cookbook "imagery" + source "nginx_imagery_layer_fragment.conf.erb" + owner "root" + group "root" + mode 0644 + variables new_resource.to_hash + notifies :reload, "service[nginx]", :delayed + end + +end + +action :delete do + service "mapserv-fgi-layer-#{name}.conf" do + provider Chef::Provider::Service::Upstart + action [:stop, :disable] + supports :status => true, :restart => true, :reload => false + end + + file "/srv/imagery/mapserver/layer-#{name}.map" do + action :delete + end + + file "/etc/init/mapserv-fgi-layer-#{name}.conf" do + action :delete + end + + file "/srv/imagery/nginx/#{site}/layer-#{name}.conf" do + action :delete + notifies :reload, "service[nginx]", :delayed + end end diff --git a/cookbooks/imagery/templates/default/nginx_imagery.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb index 5b3b91eb4..5158aba73 100644 --- a/cookbooks/imagery/templates/default/nginx_imagery.conf.erb +++ b/cookbooks/imagery/templates/default/nginx_imagery.conf.erb @@ -2,7 +2,6 @@ server { listen 80; server_name <%= @name %>; - #FIXME WIP - #Needs to include or iterate through layers with rewrite + fastcgi - #Git checkout of web? + include /srv/imagery/nginx/<%= @name %>/layer-*.conf + } diff --git a/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb new file mode 100644 index 000000000..f5d687f68 --- /dev/null +++ b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb @@ -0,0 +1,8 @@ +# DO NOT EDIT - This file is being maintained by Chef + +location ~* "^/layer/<%= @name %>/(\d+)/(\d+)/(\d+)\.(png|jpg|jpeg)$" { + fastcgi_param QUERY_STRING "map=/srv/imagery/<%= @name %>.map&mode=tile&layers=<%= @name %>&tilemode=gmap&tile=$2+$3+$1"; + fastcgi_pass "unix:/var/run/mapserver-fastcgi/layer-<%= @name %>.socket"; + include fastcgi_params; + gzip off; +}