proxy_cache_path /data/nginx/cache/metrics levels=1:2 keys_zone=metrics:10m max_size=10g
                 inactive=60m use_temp_path=off;

upstream metrics_upstream {
    server metrics.xai-corp.net:3001;
    #server tasks.metrics_graphana:3001;

    server dkhost.xai-corp.net:3001   backup;
}

# xaibox.xai-corp.net
server {
    listen  443 ssl;
    server_name metrics.xai-corp.net;
    ssl_certificate     /etc/letsencrypt/live/xai-corp.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/xai-corp.net/privkey.pem;

    client_max_body_size 200m;

    # this is the internal Docker DNS, cache only for 30s
    resolver 127.0.0.11 valid=5s;

    set $backend http://metrics_app:3001;

    #Strict-Transport-Security: max-age=15768000
    add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;

    location / {
        proxy_set_header        Connection $http_connection;
        proxy_set_header        Host $host:$server_port;
        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 $host;
        proxy_set_header        X-Forwarded-Proto $scheme;
        proxy_pass http://metrics_upstream;

        proxy_connect_timeout   3s;
    }

}
