diff --git a/cookbooks/web/recipes/frontend.rb b/cookbooks/web/recipes/frontend.rb index d48bebfc6..9b7489ec0 100644 --- a/cookbooks/web/recipes/frontend.rb +++ b/cookbooks/web/recipes/frontend.rb @@ -27,6 +27,7 @@ admins = data_bag_item("apache", "admins") web_passwords = data_bag_item("web", "passwords") +admins = data_bag_item("apache", "admins") apache_module "alias" apache_module "expires" @@ -77,13 +78,30 @@ statuscakelocations = JSON.parse(IO.read("#{Chef::Config[:file_cache_path]}/statuscake-locations.json")) +remote_file "#{Chef::Config[:file_cache_path]}/fastly-ip-list.json" do + source "https://api.fastly.com/public-ip-list" + compile_time true + ignore_failure true +end + +fastlyips = JSON.parse(IO.read("#{Chef::Config[:file_cache_path]}/fastly-ip-list.json")) + +remote_file "#{Chef::Config[:file_cache_path]}/statuscake-locations.json" do + source "https://app.statuscake.com/Workfloor/Locations.php?format=json" + compile_time true + ignore_failure true +end + +statuscakelocations = JSON.parse(IO.read("#{Chef::Config[:file_cache_path]}/statuscake-locations.json")) + apache_site "www.openstreetmap.org" do template "apache.frontend.erb" - variables :fastly => fastlyips["addresses"] + fastlyips["ipv6_addresses"], + variables :admins => admins["hosts"], + :cloudflare => cloudflare_ipv4 + cloudflare_ipv6, + :fastly => fastlyips["addresses"] + fastlyips["ipv6_addresses"], + :secret_key_base => web_passwords["secret_key_base"], :statuscake => statuscakelocations.flat_map { |_, v| [v["ip"], v["ipv6"]] }, - :admins => admins["hosts"], - :status => node[:web][:status], - :secret_key_base => web_passwords["secret_key_base"] + :status => node[:web][:status] end template "/etc/logrotate.d/apache2" do diff --git a/cookbooks/web/templates/default/apache.frontend.erb b/cookbooks/web/templates/default/apache.frontend.erb index f105236e5..0697ddbee 100644 --- a/cookbooks/web/templates/default/apache.frontend.erb +++ b/cookbooks/web/templates/default/apache.frontend.erb @@ -31,7 +31,32 @@ ErrorLog /var/log/apache2/error.log # Fastly POPs <% @fastly.sort.each do |address| -%> RemoteIPTrustedProxy <%= address %> + Require ip <%= address %> <% end -%> + # Fastly POPs +<% @fastly.sort.each do |address| -%> + Require ip <%= address %> + RemoteIPTrustedProxy <%= address %> +<% end -%> + # StatusCake monitoring +<% @statuscake.sort.reject { |address| address.empty? }.each do |address| -%> + Require ip <%= address %> +<% end -%> + # Administrators +<% @admins.sort.each do |address| -%> + Require ip <%= address %> +<% end -%> + # OSM Amsterdam IPv4 + Require ip 184.104.179.128/27 + # OSM Amsterdam IPv6 + Require ip 2001:470:1:fa1::/64 + # OSM Dublin IPv4 + Require ip 184.104.226.96/27 + # OSM Dublin IPv6 + Require ip 2001:470:1:b3b::/64 + # OSM UCL IPv4 + Require ip 193.60.236.0/24 + # # Turn on various features