]> git.openstreetmap.org Git - chef.git/commitdiff
Whitelist web frontends in nominatim fail2ban jail
authorTom Hughes <tom@compton.nu>
Fri, 27 Nov 2020 10:45:31 +0000 (10:45 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 27 Nov 2020 10:45:51 +0000 (10:45 +0000)
cookbooks/nominatim/recipes/default.rb

index 75c357902ce071b83e5df6fb5103b66919222eb3..fc6d2e9e3d5408d439392b26886ecef807eabe3b 100644 (file)
@@ -412,11 +412,13 @@ nginx_site "default" do
   action [:delete]
 end
 
+frontends = search(:node, "recipes:web\\:\\:frontend")
+
 nginx_site "nominatim" do
   template "nginx.erb"
   directory build_directory
   variables :pools => node[:nominatim][:fpm_pools],
-            :frontends => search(:node, "recipes:web\\:\\:frontend"),
+            :frontends => frontends,
             :confdir => "#{basedir}/etc",
             :ui_directory => ui_directory
 end
@@ -454,9 +456,12 @@ end
 
 include_recipe "fail2ban"
 
+frontend_addresses = frontends.collect { |f| f.ipaddresses(:role => :external) }
+
 fail2ban_jail "nominatim_limit_req" do
   filter "nginx-limit-req"
   logpath "#{node[:nominatim][:logdir]}/nominatim.openstreetmap.org-error.log"
   ports [80, 443]
   maxretry 5
+  ignoreips frontend_addresses.flatten
 end