From d168351c5b49bd9689de106601c7267a19b7985b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 9 Sep 2013 10:16:00 +0100 Subject: [PATCH] Allow the listen host address to be set for apache --- cookbooks/apache/attributes/default.rb | 2 ++ cookbooks/apache/recipes/default.rb | 7 +++++++ cookbooks/apache/templates/default/ports.conf.erb | 15 +++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 cookbooks/apache/templates/default/ports.conf.erb diff --git a/cookbooks/apache/attributes/default.rb b/cookbooks/apache/attributes/default.rb index 23ef3397a..73184f049 100644 --- a/cookbooks/apache/attributes/default.rb +++ b/cookbooks/apache/attributes/default.rb @@ -25,3 +25,5 @@ default[:apache][:event][:max_spare_threads] = 75 default[:apache][:event][:thread_limit] = 64 default[:apache][:event][:threads_per_child] = 25 default[:apache][:event][:max_requests_per_child] = 0 + +default[:apache][:listen_address] = "*" diff --git a/cookbooks/apache/recipes/default.rb b/cookbooks/apache/recipes/default.rb index 9fa7fed85..4fa9b3bc3 100644 --- a/cookbooks/apache/recipes/default.rb +++ b/cookbooks/apache/recipes/default.rb @@ -29,6 +29,13 @@ template "/etc/apache2/httpd.conf" do mode 0644 end +template "/etc/apache2/ports.conf" do + source "ports.conf.erb" + owner "root" + group "root" + mode 0644 +end + service "apache2" do action [ :enable, :start ] supports :status => true, :restart => true, :reload => true diff --git a/cookbooks/apache/templates/default/ports.conf.erb b/cookbooks/apache/templates/default/ports.conf.erb new file mode 100644 index 000000000..588fcee5c --- /dev/null +++ b/cookbooks/apache/templates/default/ports.conf.erb @@ -0,0 +1,15 @@ +# DO NOT EDIT - This file is being maintained by Chef + +# Listen on port 80 +NameVirtualHost *:80 +Listen <%= node[:apache][:listen_address] %>:80 + +# Listen on port 443 if mod_ssl is enabled + + Listen <%= node[:apache][:listen_address] %>:443 + + +# Listen on port 443 if mod_gnutls is enabled + + Listen <%= node[:apache][:listen_address] %>:443 + -- 2.43.2