diff --git a/README.md b/README.md
index 5aebdf2..4c6388b 100644
--- a/README.md
+++ b/README.md
@@ -18,10 +18,11 @@ Available variables are listed below, along with default values (see `defaults/m
The repository to use when installing Apache (only used on RHEL/CentOS systems). If you'd like later versions of Apache than are available in the OS's core repositories, use a repository like EPEL (which can be installed with the `geerlingguy.repo-epel` role).
+ apache_listen_ip: "*"
apache_listen_port: 80
apache_listen_port_ssl: 443
-The ports on which apache should be listening. Useful if you have another service (like a reverse proxy) listening on port 80 or 443 and need to change the defaults.
+The IP address and ports on which apache should be listening. Useful if you have another service (like a reverse proxy) listening on port 80 or 443 and need to change the defaults.
apache_create_vhosts: true
apache_vhosts_filename: "vhosts.conf"
diff --git a/defaults/main.yml b/defaults/main.yml
index f94e8e8..b2dba08 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,6 +1,7 @@
---
apache_enablerepo: ""
+apache_listen_ip: "*"
apache_listen_port: 80
apache_listen_port_ssl: 443
diff --git a/meta/main.yml b/meta/main.yml
index 0e4c3a8..12200db 100644
--- a/meta/main.yml
+++ b/meta/main.yml
@@ -20,6 +20,7 @@ galaxy_info:
- raring
- saucy
- trusty
+ - xenial
- name: Suse
versions:
- all
diff --git a/tasks/configure-Debian.yml b/tasks/configure-Debian.yml
index 4e886a1..8728747 100644
--- a/tasks/configure-Debian.yml
+++ b/tasks/configure-Debian.yml
@@ -35,7 +35,7 @@
- name: Add apache vhosts configuration.
template:
- src: "vhosts-{{ apache_vhosts_version }}.conf.j2"
+ src: "vhosts.conf.j2"
dest: "{{ apache_conf_path }}/sites-available/{{ apache_vhosts_filename }}"
owner: root
group: root
diff --git a/tasks/configure-RedHat.yml b/tasks/configure-RedHat.yml
index 35555d8..c3e3bd2 100644
--- a/tasks/configure-RedHat.yml
+++ b/tasks/configure-RedHat.yml
@@ -20,7 +20,7 @@
- name: Add apache vhosts configuration.
template:
- src: "vhosts-{{ apache_vhosts_version }}.conf.j2"
+ src: "vhosts.conf.j2"
dest: "{{ apache_conf_path }}/{{ apache_vhosts_filename }}"
owner: root
group: root
diff --git a/tasks/configure-Solaris.yml b/tasks/configure-Solaris.yml
index 9b6505b..a95654b 100644
--- a/tasks/configure-Solaris.yml
+++ b/tasks/configure-Solaris.yml
@@ -10,7 +10,7 @@
- name: Add apache vhosts configuration.
template:
- src: "vhosts-{{ apache_vhosts_version }}.conf.j2"
+ src: "vhosts.conf.j2"
dest: "{{ apache_conf_path }}/{{ apache_vhosts_filename }}"
owner: root
group: root
diff --git a/tasks/configure-Suse.yml b/tasks/configure-Suse.yml
index 5166f0a..16d89f8 100644
--- a/tasks/configure-Suse.yml
+++ b/tasks/configure-Suse.yml
@@ -15,7 +15,7 @@
- name: Add apache vhosts configuration.
template:
- src: "vhosts-{{ apache_vhosts_version }}.conf.j2"
+ src: "vhosts.conf.j2"
dest: "{{ apache_conf_path }}/{{ apache_vhosts_filename }}"
owner: root
group: root
diff --git a/templates/vhosts-2.2.conf.j2 b/templates/vhosts-2.2.conf.j2
deleted file mode 100644
index a274405..0000000
--- a/templates/vhosts-2.2.conf.j2
+++ /dev/null
@@ -1,76 +0,0 @@
-{{ apache_global_vhost_settings }}
-
-{# Set up VirtualHosts #}
-{% for vhost in apache_vhosts %}
-
- ServerName {{ vhost.servername }}
-{% if vhost.serveralias is defined %}
- ServerAlias {{ vhost.serveralias }}
-{% endif %}
-{% if vhost.documentroot is defined %}
- DocumentRoot {{ vhost.documentroot }}
-{% endif %}
-
-{% if vhost.serveradmin is defined %}
- ServerAdmin {{ vhost.serveradmin }}
-{% endif %}
-{% if vhost.documentroot is defined %}
-
- AllowOverride All
- Options -Indexes FollowSymLinks
-{% if vhost.authuserfile is defined %}
- AuthType Basic
- AuthName "Restricted Area"
- AuthUserFile "{{ vhost.authuserfile }}"
- Require valid-user
-{% else %}
- Order allow,deny
- Allow from all
-{% endif %}
-
-{% endif %}
-{% if vhost.extra_parameters is defined %}
- {{ vhost.extra_parameters }}
-{% endif %}
-
-
-{% endfor %}
-
-{# Set up SSL VirtualHosts. #}
-{% for vhost in apache_vhosts_ssl %}
-
- ServerName {{ vhost.servername }}
-{% if vhost.serveralias is defined %}
- ServerAlias {{ vhost.serveralias }}
-{% endif %}
-{% if vhost.documentroot is defined %}
- DocumentRoot {{ vhost.documentroot }}
-{% endif %}
-
- SSLEngine on
- SSLCipherSuite {{ apache_ssl_cipher_suite }}
- SSLProtocol {{ apache_ssl_protocol }}
- SSLHonorCipherOrder On
- SSLCertificateFile {{ vhost.certificate_file }}
- SSLCertificateKeyFile {{ vhost.certificate_key_file }}
-{% if vhost.certificate_chain_file is defined %}
- SSLCertificateChainFile {{ vhost.certificate_chain_file }}
-{% endif %}
-
-{% if vhost.serveradmin is defined %}
- ServerAdmin {{ vhost.serveradmin }}
-{% endif %}
-{% if vhost.documentroot is defined %}
-
- AllowOverride All
- Options -Indexes FollowSymLinks
- Order allow,deny
- Allow from all
-
-{% endif %}
-{% if vhost.extra_parameters is defined %}
- {{ vhost.extra_parameters }}
-{% endif %}
-
-
-{% endfor %}
diff --git a/templates/vhosts-2.4.conf.j2 b/templates/vhosts.conf.j2
similarity index 83%
rename from templates/vhosts-2.4.conf.j2
rename to templates/vhosts.conf.j2
index f2d9582..766554f 100644
--- a/templates/vhosts-2.4.conf.j2
+++ b/templates/vhosts.conf.j2
@@ -2,7 +2,7 @@
{# Set up VirtualHosts #}
{% for vhost in apache_vhosts %}
-
+
ServerName {{ vhost.servername }}
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}
@@ -18,11 +18,9 @@
AllowOverride All
Options -Indexes +FollowSymLinks
-{% if vhost.authuserfile is defined %}
- AuthType Basic
- AuthName "Restricted Area"
- AuthUserFile "{{ vhost.authuserfile }}"
- Require valid-user
+{% if apache_vhosts_version == "2.2" %}
+ Order allow,deny
+ Allow from all
{% else %}
Require all granted
{% endif %}
@@ -38,7 +36,7 @@
{# Set up SSL VirtualHosts #}
{% for vhost in apache_vhosts_ssl %}
{% if apache_ignore_missing_ssl_certificate or apache_ssl_certificates.results[loop.index0].stat.exists %}
-
+
ServerName {{ vhost.servername }}
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}
@@ -51,7 +49,9 @@
SSLCipherSuite {{ apache_ssl_cipher_suite }}
SSLProtocol {{ apache_ssl_protocol }}
SSLHonorCipherOrder On
+{% if apache_vhosts_version == "2.4" %}
SSLCompression off
+{% endif %}
SSLCertificateFile {{ vhost.certificate_file }}
SSLCertificateKeyFile {{ vhost.certificate_key_file }}
{% if vhost.certificate_chain_file is defined %}
@@ -65,7 +65,12 @@
AllowOverride All
Options -Indexes +FollowSymLinks
+{% if apache_vhosts_version == "2.2" %}
+ Order allow,deny
+ Allow from all
+{% else %}
Require all granted
+{% endif %}
{% endif %}
{% if vhost.extra_parameters is defined %}
diff --git a/vars/RedHat.yml b/vars/RedHat.yml
index c4a4725..6f608a9 100644
--- a/vars/RedHat.yml
+++ b/vars/RedHat.yml
@@ -18,4 +18,4 @@ apache_ports_configuration_items:
- regexp: "^Listen "
line: "Listen {{ apache_listen_port }}"
- regexp: "^#?NameVirtualHost "
- line: "NameVirtualHost *:{{ apache_listen_port }}"
+ line: "NameVirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}"
diff --git a/vars/Solaris.yml b/vars/Solaris.yml
index 351fefa..576291e 100644
--- a/vars/Solaris.yml
+++ b/vars/Solaris.yml
@@ -16,4 +16,4 @@ apache_ports_configuration_items:
- regexp: "^Listen "
line: "Listen {{ apache_listen_port }}"
- regexp: "^#?NameVirtualHost "
- line: "NameVirtualHost *:{{ apache_listen_port }}"
+ line: "NameVirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}"
diff --git a/vars/Suse.yml b/vars/Suse.yml
index ad26609..27703f3 100644
--- a/vars/Suse.yml
+++ b/vars/Suse.yml
@@ -15,4 +15,4 @@ apache_ports_configuration_items:
- regexp: "^Listen "
line: "Listen {{ apache_listen_port }}"
- regexp: "^#?NameVirtualHost "
- line: "NameVirtualHost *:{{ apache_listen_port }}"
+ line: "NameVirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}"
diff --git a/vars/apache-22.yml b/vars/apache-22.yml
index 97fba44..c932f93 100644
--- a/vars/apache-22.yml
+++ b/vars/apache-22.yml
@@ -8,5 +8,5 @@ apache_ports_configuration_items:
}
- {
regexp: "^#?NameVirtualHost ",
- line: "NameVirtualHost *:{{ apache_listen_port }}"
+ line: "NameVirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}"
}