fix vhostname

This commit is contained in:
Antonio J. Delgado 2022-12-08 14:00:05 +02:00
parent fb909d1a2c
commit 83ca2386b0
3 changed files with 15 additions and 15 deletions

View file

@ -79,7 +79,7 @@ There are similar list of objects supported by Nagios like:
The list vhosts contains at least one virtual host to configure Apache2.
```yaml
- vhost_name: nagios4.example.org
- vhostname: nagios4.example.org
serveradmin: webmaster@example.org
vhost_aliases: nagios.example.org
ssl_certificate_file: "/etc/letsencrypt/live/nagios4.example.org/fullchain.pem"

View file

@ -1,7 +1,7 @@
---
- name: Ensure configuration file is available to Apache
template:
dest: "/etc/apache2/sites-available/25-{{ item.vhost_name }}.conf"
dest: "/etc/apache2/sites-available/25-{{ item.vhostname }}.conf"
src: templates/apache_vhost.j2
mode: 0644
backup: yes
@ -19,7 +19,7 @@
- name: Ensure vhost is enabled
file:
state: link
src: "/etc/apache2/sites-available/25-{{ item.vhost_name }}.conf"
path: "/etc/apache2/sites-enabled/25-{{ item.vhost_name }}.conf"
src: "/etc/apache2/sites-available/25-{{ item.vhostname }}.conf"
path: "/etc/apache2/sites-enabled/25-{{ item.vhostname }}.conf"
loop: "{{ vhosts }}"
notify: Restart Apache2
notify: Restart Apache2

View file

@ -1,14 +1,14 @@
<VirtualHost *:80>
ServerName {{ item.vhost_name }}
ServerAdmin {{ item.webadmin | default('webmaster@' + item.vhost_name) }}
ServerName {{ item.vhostname }}
ServerAdmin {{ item.webadmin | default('webmaster@' + item.vhostname) }}
{% if item.vhost_aliases is defined %}
ServerAlias {{ item.vhost_aliases }}
{% endif %}
## Logging
ErrorLog "/var/log/apache2/{{ item.vhost_name }}_error_ssl.log"
ErrorLog "/var/log/apache2/{{ item.vhostname }}_error_ssl.log"
ServerSignature Off
CustomLog "/var/log/apache2/{{ item.vhost_name }}_access_ssl.log" combined
CustomLog "/var/log/apache2/{{ item.vhostname }}_access_ssl.log" combined
ErrorDocument 404 https://susurrando.com/notfound.php
ErrorDocument 500 https://susurrando.com/error500.php
ErrorDocument 503 https://susurrando.com/error503.php
@ -94,13 +94,13 @@
</VirtualHost>
<VirtualHost *:443>
ServerName {{ item.vhost_name }}
ServerName {{ item.vhostname }}
ServerAdmin {{ item.webadmin }}
## Logging
ErrorLog "/var/log/apache2/{{ item.vhost_name }}_ssl_error_ssl.log"
ErrorLog "/var/log/apache2/{{ item.vhostname }}_ssl_error_ssl.log"
ServerSignature Off
CustomLog "/var/log/apache2/{{ item.vhost_name }}_ssl_access_ssl.log" combined
CustomLog "/var/log/apache2/{{ item.vhostname }}_ssl_access_ssl.log" combined
ErrorDocument 404 https://susurrando.com/notfound.php
ErrorDocument 500 https://susurrando.com/error500.php
ErrorDocument 503 https://susurrando.com/error503.php
@ -125,6 +125,6 @@
SSLProxyEngine On
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
ProxyPass / http://{{ item.vhost_name }}/
ProxyPassReverse / http://{{ item.vhost_name }}/
</VirtualHost>
ProxyPass / http://{{ item.vhostname }}/
ProxyPassReverse / http://{{ item.vhostname }}/
</VirtualHost>