infra/roles/monitoring-server/templates/01-grafana.j2

58 lines
1.8 KiB
Django/Jinja

server {
listen 443 ssl http2;
#listen [::]:443 ssl; # listen for ipv6
{% if inventory_hostname in wg_clients -%}
listen {{ wg_clients[inventory_hostname].ip }}:443 ssl http2;
{% endif -%}
include /etc/nginx/authelia_internal.conf;
include /etc/nginx/listen-proxy-protocol.conf;
server_name {{ grafana_url }};
location ~ ^/api/health {
allow 127.0.0.1;
{% if inventory_hostname in my_public_ips -%}
allow {{ my_public_ips[inventory_hostname] }}/32;
{% endif -%}
allow {{ my_public_ips[ansible_control_host] }}/32;
#deny all;
allow all;
proxy_pass http://127.0.0.1:{{ grafana_port }};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
location / {
include /etc/nginx/require_auth.conf;
include /etc/nginx/require_auth_proxy.conf;
proxy_pass http://127.0.0.1:{{ grafana_port }};
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
access_log /var/log/nginx/access_{{ grafana_url }}.log main;
error_log /var/log/nginx/error_{{ grafana_url }}.log warn;
ssl_session_timeout 5m;
ssl_certificate /usr/local/etc/certs/{{ grafana_url }}/fullchain.pem;
ssl_certificate_key /usr/local/etc/certs/{{ grafana_url }}/privkey.pem;
add_header Referrer-Policy "no-referrer" always;
add_header X-Download-Options "noopen" always;
add_header X-Robots-Tag "none" always;
add_header Content-Security-Policy "frame-ancestors 'self' https://*.{{ domain }};" always;
fastcgi_hide_header X-Powered-By;
}