<VirtualHost *:{{ zabbix_apache_vhost_port }}>
  ServerName {{ zabbix_apache_servername }}
  {% for alias in zabbix_url_aliases %}
  ServerAlias {{ alias }}
  {% endfor %}

  ## Vhost docroot
  DocumentRoot "/usr/share/zabbix"

{% set directory_paths = ['/usr/share/zabbix/conf', '/usr/share/zabbix/app', '/usr/share/zabbix/include', '/usr/share/zabbix/include/classes'] %}

  <Directory "/usr/share/zabbix">
  {% if apache_version|string() == '2.4' %}
    Options FollowSymLinks
    AllowOverride None
    Require all granted
  {% else %}
    AllowOverride None
    Order Allow,Deny
    Allow from all
  {% endif %}
  </Directory>

{% for my_path in directory_paths %}
  <Directory "{{ my_path }}">
  {% if apache_version|string() == '2.4' %}
    Require all granted
  {% else %}
    AllowOverride None
    Order Deny,Allow
    Deny from all
  {% endif %}
  </Directory>

{% endfor %}
  ## Logging
  ErrorLog "/var/log/{{ apache_log }}/{{ zabbix_apache_servername }}_error.log"
  ServerSignature Off
  CustomLog "/var/log/{{ apache_log }}/{{ zabbix_apache_servername }}_access.log" combined

  ## Rewrite rules
  RewriteEngine On
  RewriteRule ^$ /index.php [L]

  ## Custom fragment
  php_value max_execution_time {{ zabbix_web_max_execution_time | default('300') }}
  php_value memory_limit {{ zabbix_web_memory_limit | default('128M') }}
  php_value post_max_size {{ zabbix_web_post_max_size | default('16M') }}
  php_value upload_max_filesize {{ zabbix_web_upload_max_filesize | default('2M') }}
  php_value max_input_time {{ zabbix_web_max_input_time | default('300') }}
  # Set correct timezone.
  php_value date.timezone {{ zabbix_timezone }}
</VirtualHost>
