Add configuration for listen address

By default I leave it as "*", but for many cases, we don't want to bind our
apache to all network addresses available for the server. For example if we
want to only bind the apache to the localhost, we can use the following
configuration:

  apache_listen_ip: "127.0.0.1"
This commit is contained in:
Adam Papai 2016-04-20 11:46:12 +02:00
parent 1bbf949a9f
commit 547c0b404c
No known key found for this signature in database
GPG key ID: 662EFFB3A9A43B51
7 changed files with 9 additions and 8 deletions

View file

@ -1,6 +1,7 @@
---
apache_enablerepo: ""
apache_listen_ip: "*"
apache_listen_port: 80
apache_listen_port_ssl: 443

View file

@ -2,7 +2,7 @@
{# Set up VirtualHosts #}
{% for vhost in apache_vhosts %}
<VirtualHost *:{{ apache_listen_port }}>
<VirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}>
ServerName {{ vhost.servername }}
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}
@ -31,7 +31,7 @@
{# Set up SSL VirtualHosts. #}
{% for vhost in apache_vhosts_ssl %}
<VirtualHost *:{{ apache_listen_port_ssl }}>
<VirtualHost {{ apache_listen_ip }}:{{ apache_listen_port_ssl }}>
ServerName {{ vhost.servername }}
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}

View file

@ -2,7 +2,7 @@
{# Set up VirtualHosts #}
{% for vhost in apache_vhosts %}
<VirtualHost *:{{ apache_listen_port }}>
<VirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}>
ServerName {{ vhost.servername }}
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}
@ -31,7 +31,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 %}
<VirtualHost *:{{ apache_listen_port_ssl }}>
<VirtualHost {{ apache_listen_ip }}:{{ apache_listen_port_ssl }}>
ServerName {{ vhost.servername }}
{% if vhost.serveralias is defined %}
ServerAlias {{ vhost.serveralias }}

View file

@ -17,4 +17,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 }}"

View file

@ -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 }}"

View file

@ -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 }}"

View file

@ -8,5 +8,5 @@ apache_ports_configuration_items:
}
- {
regexp: "^#?NameVirtualHost ",
line: "NameVirtualHost *:{{ apache_listen_port }}"
line: "NameVirtualHost {{ apache_listen_ip }}:{{ apache_listen_port }}"
}