2020-09-21 03:45:35 +00:00
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
limit_req_zone $binary_remote_addr zone=req_grafana_login:10m rate=10r/m;
|
|
|
|
|
|
|
|
upstream grafana_backend {
|
|
|
|
server 127.0.0.1:{{ grafana_port }};
|
|
|
|
}
|
|
|
|
|
2024-04-14 22:30:59 +00:00
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
default upgrade;
|
|
|
|
'' close;
|
|
|
|
}
|
|
|
|
|
2019-12-02 02:40:29 +00:00
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
{% if ansible_all_ipv6_addresses | length %}
|
|
|
|
listen [::]:80;
|
|
|
|
{% endif %}
|
|
|
|
server_name {{ grafana_domain }};
|
|
|
|
|
2020-09-21 03:45:35 +00:00
|
|
|
access_log /var/log/nginx/grafana.access.log main;
|
|
|
|
error_log /var/log/nginx/grafana.error.log warn;
|
|
|
|
|
2019-12-02 02:40:29 +00:00
|
|
|
location /.well-known/acme-challenge/ {
|
2020-08-22 14:59:26 +00:00
|
|
|
root /var/www/html;
|
2019-12-02 02:40:29 +00:00
|
|
|
try_files $uri =404;
|
|
|
|
}
|
|
|
|
|
|
|
|
{% if grafana_ssl_enabled is defined and
|
|
|
|
grafana_ssl_enabled %}
|
|
|
|
location / {
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
|
|
|
|
{% if grafana_ssl_enabled is defined and
|
|
|
|
grafana_ssl_enabled %}
|
|
|
|
server {
|
2024-04-14 22:30:59 +00:00
|
|
|
listen 443 ssl;
|
2019-12-02 02:40:29 +00:00
|
|
|
{% if ansible_all_ipv6_addresses | length %}
|
2024-04-14 22:30:59 +00:00
|
|
|
listen [::]:443 ssl;
|
2019-12-02 02:40:29 +00:00
|
|
|
{% endif %}
|
2024-04-14 22:30:59 +00:00
|
|
|
|
|
|
|
http2 on;
|
|
|
|
|
2019-12-02 02:40:29 +00:00
|
|
|
server_name {{ grafana_domain }};
|
|
|
|
|
2020-09-21 03:45:35 +00:00
|
|
|
access_log /var/log/nginx/grafana.access.log main;
|
|
|
|
error_log /var/log/nginx/grafana.error.log warn;
|
|
|
|
|
2019-12-02 02:40:29 +00:00
|
|
|
{% if grafana_ssl_certificate is defined %}
|
|
|
|
ssl_certificate {{ grafana_ssl_certificate }};
|
|
|
|
{% endif %}
|
|
|
|
{% if grafana_ssl_certificate_key is defined %}
|
|
|
|
ssl_certificate_key {{ grafana_ssl_certificate_key }};
|
|
|
|
{% endif %}
|
|
|
|
{% if grafana_ssl_dhparam is defined %}
|
|
|
|
ssl_dhparam {{ grafana_ssl_dhparam }};
|
|
|
|
{% endif %}
|
|
|
|
|
2022-08-30 12:09:23 +00:00
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
|
2020-09-21 03:45:35 +00:00
|
|
|
location /login {
|
|
|
|
limit_req zone=req_grafana_login burst=10;
|
|
|
|
proxy_pass http://grafana_backend;
|
|
|
|
}
|
|
|
|
|
2019-12-02 02:40:29 +00:00
|
|
|
location / {
|
2024-04-14 22:30:59 +00:00
|
|
|
add_header Alt-Svc 'h3=":$server_port"; ma=86400';
|
2020-09-21 03:45:35 +00:00
|
|
|
limit_req zone=req_bad_actors burst=10 nodelay;
|
2024-04-14 22:30:59 +00:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
proxy_set_header Host $http_host;
|
2020-09-21 03:45:35 +00:00
|
|
|
proxy_pass http://grafana_backend;
|
2019-12-02 02:40:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
{% endif %}
|