]> git.openstreetmap.org Git - chef.git/commitdiff
Treat fastly addresses as trusted sources of remote IP addresses
authorTom Hughes <tom@compton.nu>
Sun, 15 Nov 2020 15:12:58 +0000 (15:12 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 15 Nov 2020 15:13:24 +0000 (15:13 +0000)
cookbooks/tile/recipes/default.rb
cookbooks/tile/templates/default/apache.erb

index 7363e410cd3fe945b20463defa6917330d17ab89..241b73a8e9283d6be225a88cbaf035bd067d35e9 100644 (file)
@@ -46,7 +46,13 @@ ssl_certificate node[:fqdn] do
   notifies :reload, "service[apache2]"
 end
 
+remote_file "#{Chef::Config[:file_cache_path]}/fastly-ip-list.json" do
+  source "https://api.fastly.com/public-ip-list"
+  compile_time true
+end
+
 tilecaches = search(:node, "roles:tilecache").sort_by { |n| n[:hostname] }
+fastlyips = JSON.parse(IO.read("#{Chef::Config[:file_cache_path]}/fastly-ip-list.json"))
 
 apache_site "default" do
   action [:disable]
@@ -54,7 +60,7 @@ end
 
 apache_site "tile.openstreetmap.org" do
   template "apache.erb"
-  variables :caches => tilecaches
+  variables :caches => tilecaches, :fastly => fastlyips["addresses"]
 end
 
 template "/etc/logrotate.d/apache2" do
index 0e461b8d60c0d006a6edd6a02e222500e4afb62b..e6f8ade1cbb135d3aa427acdb80e50b134183c06 100644 (file)
@@ -25,6 +25,9 @@
 <% cache.ipaddresses(:role => :external).sort.each do |address| -%>
   RemoteIPTrustedProxy <%= address %>
 <% end -%>
+<% end -%>
+<% @fastly.sort.each do |address| -%>
+  RemoteIPTrustedProxy <%= address %>
 <% end -%>
 
   # Setup logging