<VirtualHost *:80 *:443>
  ServerName {{ nextcloud_domains[0] }}
  
  {% for domain_alias in nextcloud_domains[1:] %}
  ServerAlias {{  domain_alias }}
  {% endfor %}

  # SSL
  # SSLEngine on
  # SSLCertificateFile    /etc/letsencrypt/live/{{ nextcloud_instance_name }}/fullchain.pem
  # SSLCertificateKeyFile /etc/letsencrypt/live/{{ nextcloud_instance_name }}/privkey.pem
  # Header always set Strict-Transport-Security "max-age=15552000"

  DocumentRoot {{ nextcloud_webroot }}/

  <Directory {{ nextcloud_webroot }}/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
  </Directory>

  <Directory {{ nextcloud_data }}/>
    Require all denied
    AllowOverride None

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
  </Directory>

  # SSL Redirect
  # RewriteEngine On
  # RewriteCond %{HTTPS} !=on
  # RewriteCond %{HTTP:X-Forwarded-Proto} !=https
  # RewriteRule ^ https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

  # ITK
  AssignUserID {{ nextcloud_user }} {{ nextcloud_user }}

  # LOG
  CustomLog /var/log/apache2/access.log vhost_combined
  ErrorLog  /var/log/apache2/error.log

  # PHP
  php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f {{ nextcloud_user }}"
  php_admin_value open_basedir "/usr/share/php:{{ nextcloud_home }}:/tmp"

</VirtualHost>