diff options
Diffstat (limited to 'roles/apache_server/templates/virtualhost.conf.tmpl')
-rw-r--r-- | roles/apache_server/templates/virtualhost.conf.tmpl | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/roles/apache_server/templates/virtualhost.conf.tmpl b/roles/apache_server/templates/virtualhost.conf.tmpl index 1fa060a..5d06f0e 100644 --- a/roles/apache_server/templates/virtualhost.conf.tmpl +++ b/roles/apache_server/templates/virtualhost.conf.tmpl @@ -7,6 +7,36 @@ DocumentRoot /srv/http/{{ item.domain }} ErrorLog /var/log/apache2/{{ item.domain }}/error.log CustomLog /var/log/apache2/{{ item.domain }}/access.log combined +{% if item.letsencrypt|default(false) %} + Redirect permanent / "https://{{ item.domain }}/" +{% else %} + <Directory /srv/http/{{ item.domain }}> + + Options +SymlinksIfOwnerMatch +Indexes +MultiViews +{% if item.htpasswd is defined %} + AuthType Basic + AuthName "{{ item.htpasswd_name }}" + AuthUserFile "/srv/http/{{ item.domain }}.htpasswd" + Require valid-user +{% else %} + AllowOverride AuthConfig + Require all granted +{% endif %} + </Directory> +{% endif %} +</VirtualHost> + + +{% if item.letsencrypt|default(false) %} +<VirtualHost _default_:443> + ServerName {{ item.domain }} +{% if item.alias is defined %} + ServerAlias {{ item.alias }} +{% endif %} + ServerAdmin {{ item.ownermail }} + DocumentRoot /srv/http/{{ item.domain }} + ErrorLog /var/log/apache2/{{ item.domain }}/error.log + CustomLog /var/log/apache2/{{ item.domain }}/access.log combined <Directory /srv/http/{{ item.domain }}> Options +SymlinksIfOwnerMatch +Indexes +MultiViews {% if item.htpasswd is defined %} @@ -19,4 +49,9 @@ Require all granted {% endif %} </Directory> + + SSLEngine on + SSLCertificateFile "/etc/letsencrypt/live/{{ letsencrypt_main_domain }}/fullchain.pem" + SSLCertificateKeyFile "/etc/letsencrypt/live/{{ letsencrypt_main_domain }}/privkey.pem" </VirtualHost> +{% endif %} |