| 1 |
# Nginx configuration for Zabbix Web |
| 2 |
|
| 3 |
server { |
| 4 |
listen {{ zabbix_web_vhost_port }}; |
| 5 |
listen [::]:{{ zabbix_web_vhost_port }}; |
| 6 |
server_tokens off; |
| 7 |
server_name {{ zabbix_api_server_url }} {% for alias in zabbix_url_aliases -%}{{ alias -}} {% endfor %}; |
| 8 |
|
| 9 |
{% if zabbix_web_redirect|default(false) and zabbix_web_tls|default(false) %} |
| 10 |
return 301 https://{{ zabbix_api_server_url }}$request_uri; |
| 11 |
{% else %} |
| 12 |
|
| 13 |
{% if zabbix_web_version is version('7.0', '<=') %} |
| 14 |
root /usr/share/zabbix; |
| 15 |
{% else %} |
| 16 |
root /usr/share/zabbix/ui; |
| 17 |
{% endif %} |
| 18 |
|
| 19 |
index index.php; |
| 20 |
|
| 21 |
location = /favicon.ico { |
| 22 |
log_not_found off; |
| 23 |
} |
| 24 |
|
| 25 |
location / { |
| 26 |
try_files $uri $uri/ =404; |
| 27 |
} |
| 28 |
|
| 29 |
location /assets/ { |
| 30 |
access_log off; |
| 31 |
expires 10d; |
| 32 |
} |
| 33 |
|
| 34 |
location ~ /\.ht { |
| 35 |
deny all; |
| 36 |
} |
| 37 |
|
| 38 |
location ~ /(api\/|conf[^\.]|include|locale) { |
| 39 |
deny all; |
| 40 |
return 404; |
| 41 |
} |
| 42 |
|
| 43 |
location ~ [^/]\.php(/|$) { |
| 44 |
fastcgi_pass unix:{{ zabbix_php_fpm_listen }}; |
| 45 |
fastcgi_split_path_info ^(.+\.php)(/.+)$; |
| 46 |
fastcgi_index index.php; |
| 47 |
|
| 48 |
{% if zabbix_web_version is version('7.0', '<=') %} |
| 49 |
fastcgi_param DOCUMENT_ROOT /usr/share/zabbix; |
| 50 |
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name; |
| 51 |
fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name; |
| 52 |
{% else %} |
| 53 |
fastcgi_param DOCUMENT_ROOT /usr/share/zabbix/ui; |
| 54 |
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix/ui$fastcgi_script_name; |
| 55 |
fastcgi_param PATH_TRANSLATED /usr/share/zabbix/ui$fastcgi_script_name; |
| 56 |
{% endif %} |
| 57 |
|
| 58 |
include fastcgi_params; |
| 59 |
fastcgi_param QUERY_STRING $query_string; |
| 60 |
fastcgi_param REQUEST_METHOD $request_method; |
| 61 |
fastcgi_param CONTENT_TYPE $content_type; |
| 62 |
fastcgi_param CONTENT_LENGTH $content_length; |
| 63 |
|
| 64 |
fastcgi_intercept_errors on; |
| 65 |
fastcgi_ignore_client_abort off; |
| 66 |
fastcgi_connect_timeout 60; |
| 67 |
fastcgi_send_timeout 180; |
| 68 |
fastcgi_read_timeout 180; |
| 69 |
fastcgi_buffer_size 128k; |
| 70 |
fastcgi_buffers 4 256k; |
| 71 |
fastcgi_busy_buffers_size 256k; |
| 72 |
fastcgi_temp_file_write_size 256k; |
| 73 |
} |
| 74 |
{% endif %} |
| 75 |
} |
| 76 |
|
| 77 |
{% if zabbix_web_tls|default(false) %} |
| 78 |
server { |
| 79 |
listen {{ zabbix_web_vhost_tls_port }} ssl; |
| 80 |
{{ 'http2 on;' if zabbix_web_ssl_http2 else '' }} |
| 81 |
listen [::]:{{ zabbix_web_vhost_tls_port }} ssl |
| 82 |
{{ 'http2 on;' if zabbix_web_ssl_http2 else '' }}; |
| 83 |
server_tokens off; |
| 84 |
server_name {{ zabbix_api_server_url }} {% for alias in zabbix_url_aliases -%}{{ alias -}} {% endfor %}; |
| 85 |
|
| 86 |
ssl_certificate {{ zabbix_web_tls_crt }}; |
| 87 |
ssl_certificate_key {{ zabbix_web_tls_key }}; |
| 88 |
{{ (zabbix_web_ssl_cipher_suite is defined and zabbix_web_ssl_cipher_suite is not none) | ternary('', '# ') }}ssl_ciphers {{ zabbix_web_ssl_cipher_suite | default('') }}; |
| 89 |
{{ (zabbix_web_ssl_session_cache is defined and zabbix_web_ssl_session_cache != "!INVALID") | ternary('', '# ') }}ssl_session_cache {{ zabbix_web_ssl_session_cache | default('') }}; |
| 90 |
{{ (zabbix_web_ssl_session_cache_timeout is defined and zabbix_web_ssl_session_cache_timeout != "!INVALID") | ternary('', '# ') }}ssl_session_timeout {{ zabbix_web_ssl_session_cache_timeout | default('') }}; |
| 91 |
{{ (zabbix_web_ssl_session_protocols is defined and zabbix_web_ssl_session_protocols is not none) | ternary('', '# ') }}ssl_protocols {{ zabbix_web_ssl_session_protocols | default('') }}; |
| 92 |
{{ (zabbix_web_ssl_session_prefer_server_ciphers is defined and zabbix_web_ssl_session_prefer_server_ciphers is not none) | ternary('', '# ') }}ssl_prefer_server_ciphers {{ zabbix_web_ssl_session_prefer_server_ciphers | default('') }}; |
| 93 |
{{ (zabbix_web_ssl_session_stapling is defined and zabbix_web_ssl_session_stapling is not none) | ternary('', '# ') }}ssl_stapling {{ zabbix_web_ssl_session_stapling | default('') }}; |
| 94 |
|
| 95 |
{% if zabbix_web_version is version('7.0', '<=') %} |
| 96 |
root /usr/share/zabbix; |
| 97 |
{% else %} |
| 98 |
root /usr/share/zabbix/ui; |
| 99 |
{% endif %} |
| 100 |
|
| 101 |
index index.php; |
| 102 |
|
| 103 |
location = /favicon.ico { |
| 104 |
log_not_found off; |
| 105 |
} |
| 106 |
|
| 107 |
location / { |
| 108 |
try_files $uri $uri/ =404; |
| 109 |
} |
| 110 |
|
| 111 |
location /assets/ { |
| 112 |
access_log off; |
| 113 |
expires 10d; |
| 114 |
} |
| 115 |
|
| 116 |
location ~ /\.ht { |
| 117 |
deny all; |
| 118 |
} |
| 119 |
|
| 120 |
location ~ /(api\/|conf[^\.]|include|locale) { |
| 121 |
deny all; |
| 122 |
return 404; |
| 123 |
} |
| 124 |
|
| 125 |
location ~ [^/]\.php(/|$) { |
| 126 |
fastcgi_pass unix:{{ zabbix_php_fpm_listen }}; |
| 127 |
fastcgi_split_path_info ^(.+\.php)(/.+)$; |
| 128 |
fastcgi_index index.php; |
| 129 |
|
| 130 |
{% if zabbix_web_version is version('7.0', '<=') %} |
| 131 |
fastcgi_param DOCUMENT_ROOT /usr/share/zabbix; |
| 132 |
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name; |
| 133 |
fastcgi_param PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name; |
| 134 |
{% else %} |
| 135 |
fastcgi_param DOCUMENT_ROOT /usr/share/zabbix/ui; |
| 136 |
fastcgi_param SCRIPT_FILENAME /usr/share/zabbix/ui$fastcgi_script_name; |
| 137 |
fastcgi_param PATH_TRANSLATED /usr/share/zabbix/ui$fastcgi_script_name; |
| 138 |
{% endif %} |
| 139 |
|
| 140 |
include fastcgi_params; |
| 141 |
fastcgi_param QUERY_STRING $query_string; |
| 142 |
fastcgi_param REQUEST_METHOD $request_method; |
| 143 |
fastcgi_param CONTENT_TYPE $content_type; |
| 144 |
fastcgi_param CONTENT_LENGTH $content_length; |
| 145 |
|
| 146 |
fastcgi_intercept_errors on; |
| 147 |
fastcgi_ignore_client_abort off; |
| 148 |
fastcgi_connect_timeout 60; |
| 149 |
fastcgi_send_timeout 180; |
| 150 |
fastcgi_read_timeout 180; |
| 151 |
fastcgi_buffer_size 128k; |
| 152 |
fastcgi_buffers 4 256k; |
| 153 |
fastcgi_busy_buffers_size 256k; |
| 154 |
fastcgi_temp_file_write_size 256k; |
| 155 |
} |
| 156 |
} |
| 157 |
{% endif %} |