server {
    listen 80;
    server_name staging.geneacase.example;
    return 308 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name staging.geneacase.example;

    root /srv/geneacase/current/public;
    index index.php;
    client_max_body_size 26m;

    ssl_certificate /etc/letsencrypt/live/staging.geneacase.example/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/staging.geneacase.example/privkey.pem;

    access_log /var/log/nginx/geneacase-staging-access.log;
    error_log /var/log/nginx/geneacase-staging-error.log warn;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
        fastcgi_read_timeout 60s;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    location ~* \.(?:env|ini|log|sql|bak|old|dist)$ {
        deny all;
    }

    location = /api/v1/health/live {
        access_log off;
    }

    location = /api/v1/health/ready {
        access_log off;
    }
}
