| 1 |
<VirtualHost {{ zabbix_web_vhost_listen_ip }}:{{ zabbix_web_vhost_port }}> |
| 2 |
ServerName {{ zabbix_api_server_url }} |
| 3 |
{% for alias in zabbix_url_aliases %} |
| 4 |
ServerAlias {{ alias }} |
| 5 |
{% endfor %} |
| 6 |
|
| 7 |
## Vhost docroot |
| 8 |
DocumentRoot "/usr/share/{{ zabbix_web_version is version('7.0', '<=') | ternary('zabbix', 'zabbix/ui') }}" |
| 9 |
|
| 10 |
{% if zabbix_apache_custom_includes is iterable and (zabbix_apache_custom_includes | length>0) %} |
| 11 |
{% for include in zabbix_apache_custom_includes %} |
| 12 |
{{ include }} |
| 13 |
{% endfor %} |
| 14 |
{% endif %} |
| 15 |
|
| 16 |
{% if zabbix_web_redirect|default(false) and zabbix_web_tls|default(false) %} |
| 17 |
RewriteEngine On |
| 18 |
RewriteCond %{HTTPS} !=on |
| 19 |
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] |
| 20 |
{% endif %} |
| 21 |
|
| 22 |
{% set directory_paths = ['/usr/share/zabbix/conf', '/usr/share/zabbix/app', '/usr/share/zabbix/include', '/usr/share/zabbix/include/classes'] %} |
| 23 |
|
| 24 |
<Directory "/usr/share/zabbix"> |
| 25 |
{% if apache_version|string() == '2.4' %} |
| 26 |
Options FollowSymLinks |
| 27 |
AllowOverride None |
| 28 |
Require all granted |
| 29 |
{% else %} |
| 30 |
AllowOverride None |
| 31 |
Order Allow,Deny |
| 32 |
Allow from all |
| 33 |
{% endif %} |
| 34 |
|
| 35 |
<IfModule dir_module> |
| 36 |
DirectoryIndex index.php |
| 37 |
</IfModule> |
| 38 |
|
| 39 |
{% if ansible_facts['os_family'] in ["RedHat", "Suse"] %} |
| 40 |
<FilesMatch \.(php|phar)$> |
| 41 |
SetHandler "proxy:unix:{{ zabbix_php_fpm_listen }}|fcgi://localhost" |
| 42 |
</FilesMatch> |
| 43 |
{% endif %} |
| 44 |
|
| 45 |
</Directory> |
| 46 |
|
| 47 |
{% for my_path in directory_paths %} |
| 48 |
<Directory "{{ my_path }}"> |
| 49 |
{% if apache_version|string() == '2.4' %} |
| 50 |
Require all denied |
| 51 |
{% else %} |
| 52 |
AllowOverride None |
| 53 |
Order Deny,Allow |
| 54 |
Deny from all |
| 55 |
{% endif %} |
| 56 |
</Directory> |
| 57 |
|
| 58 |
{% endfor %} |
| 59 |
## Logging |
| 60 |
ErrorLog "/var/log/{{ _apache_log }}/{{ zabbix_api_server_url }}_error.log" |
| 61 |
ServerSignature Off |
| 62 |
CustomLog "/var/log/{{ _apache_log }}/{{ zabbix_api_server_url }}_access.log" combined |
| 63 |
|
| 64 |
## Rewrite rules |
| 65 |
RewriteEngine On |
| 66 |
RewriteRule ^$ /index.php [L] |
| 67 |
</VirtualHost> |
| 68 |
|
| 69 |
{# Set up TLS vhosts #} |
| 70 |
{% if zabbix_web_tls and zabbix_web_vhost_tls_port %} |
| 71 |
|
| 72 |
{{ (zabbix_web_SSLPassPhraseDialog is defined and zabbix_web_SSLPassPhraseDialog is not none) | ternary('', '# ') }}SSLPassPhraseDialog {{ zabbix_web_SSLPassPhraseDialog | default('') }} |
| 73 |
{{ (zabbix_web_ssl_session_cache is defined and zabbix_web_ssl_session_cache != "!INVALID") | ternary('', '# ') }}SSLSessionCache {{ zabbix_web_ssl_session_cache | default('') }} |
| 74 |
{{ (zabbix_web_ssl_session_cache_timeout is defined and zabbix_web_ssl_session_cache_timeout != "!INVALID") | ternary('', '# ') }}SSLSessionCacheTimeout {{ zabbix_web_ssl_session_cache_timeout | default('') }} |
| 75 |
{{ (zabbix_web_SSLCryptoDevice is defined and zabbix_web_SSLCryptoDevice is not none) | ternary('', '# ') }}SSLCryptoDevice {{ zabbix_web_SSLCryptoDevice | default('') }} |
| 76 |
SSLRandomSeed startup file:/dev/urandom 256 |
| 77 |
SSLRandomSeed connect builtin |
| 78 |
|
| 79 |
<VirtualHost {{ zabbix_web_vhost_listen_ip }}:{{ zabbix_web_vhost_tls_port }}> |
| 80 |
ServerName {{ zabbix_api_server_url }} |
| 81 |
{% for alias in zabbix_url_aliases %} |
| 82 |
ServerAlias {{ alias }} |
| 83 |
{% endfor %} |
| 84 |
|
| 85 |
## Vhost docroot |
| 86 |
{% if zabbix_web_version is version('7.0', '<=') %} |
| 87 |
DocumentRoot "/usr/share/zabbix" |
| 88 |
{% else %} |
| 89 |
DocumentRoot "/usr/share/zabbix/ui" |
| 90 |
{% endif %} |
| 91 |
|
| 92 |
{% if zabbix_apache_custom_includes is iterable and (zabbix_apache_custom_includes | length>0) %} |
| 93 |
{% for include in zabbix_apache_custom_includes %} |
| 94 |
{{ include }} |
| 95 |
{% endfor %} |
| 96 |
{% endif %} |
| 97 |
|
| 98 |
SSLEngine on |
| 99 |
{{ (zabbix_web_ssl_cipher_suite is defined and zabbix_web_ssl_cipher_suite is not none) | ternary('', '# ') }}SSLCipherSuite {{ zabbix_web_ssl_cipher_suite | default('') }} |
| 100 |
{{ (zabbix_web_ssl_cipher_suite is defined and zabbix_web_ssl_cipher_suite is not none) | ternary('', '# ') }}SSLHonorCipherOrder On |
| 101 |
{% if apache_version|string() == '2.4' %} |
| 102 |
SSLCompression off |
| 103 |
{% endif %} |
| 104 |
SSLCertificateFile {{ zabbix_web_tls_crt }} |
| 105 |
SSLCertificateKeyFile {{ zabbix_web_tls_key }} |
| 106 |
{{ (zabbix_web_tls_chain is defined and zabbix_web_tls_chain is not none) | ternary('', '# ') }}SSLCertificateChainFile {{ zabbix_web_tls_chain | default('') }} |
| 107 |
|
| 108 |
{% set directory_paths = ['/usr/share/zabbix/conf', '/usr/share/zabbix/app', '/usr/share/zabbix/include', '/usr/share/zabbix/include/classes'] %} |
| 109 |
|
| 110 |
<Directory "/usr/share/zabbix"> |
| 111 |
{% if apache_version|string() == '2.4' %} |
| 112 |
Options FollowSymLinks |
| 113 |
AllowOverride None |
| 114 |
Require all granted |
| 115 |
{% else %} |
| 116 |
AllowOverride None |
| 117 |
Order Allow,Deny |
| 118 |
Allow from all |
| 119 |
{% endif %} |
| 120 |
|
| 121 |
<IfModule dir_module> |
| 122 |
DirectoryIndex index.php |
| 123 |
</IfModule> |
| 124 |
|
| 125 |
{% if ansible_facts['os_family'] in ["RedHat", "Suse"] %} |
| 126 |
<FilesMatch \.(php|phar)$> |
| 127 |
SetHandler "proxy:unix:{{ zabbix_php_fpm_listen }}|fcgi://localhost" |
| 128 |
</FilesMatch> |
| 129 |
{% endif %} |
| 130 |
|
| 131 |
</Directory> |
| 132 |
|
| 133 |
{% for my_path in directory_paths %} |
| 134 |
<Directory "{{ my_path }}"> |
| 135 |
{% if apache_version|string() == '2.4' %} |
| 136 |
Require all granted |
| 137 |
{% else %} |
| 138 |
AllowOverride None |
| 139 |
Order Deny,Allow |
| 140 |
Deny from all |
| 141 |
{% endif %} |
| 142 |
</Directory> |
| 143 |
|
| 144 |
{% endfor %} |
| 145 |
## Logging |
| 146 |
ErrorLog "/var/log/{{ _apache_log }}/{{ zabbix_api_server_url }}_tls_error.log" |
| 147 |
ServerSignature Off |
| 148 |
CustomLog "/var/log/{{ _apache_log }}/{{ zabbix_api_server_url }}_tls_access.log" combined |
| 149 |
|
| 150 |
## Rewrite rules |
| 151 |
RewriteEngine On |
| 152 |
RewriteRule ^$ /index.php [L] |
| 153 |
|
| 154 |
</VirtualHost> |
| 155 |
{% endif %} |