server {
    listen 80;
    server_name erp.example.edu;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name erp.example.edu;
    root /var/www/university-erp/current/public;
    index index.php;

    ssl_certificate /etc/letsencrypt/live/erp.example.edu/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/erp.example.edu/privkey.pem;
    add_header X-Content-Type-Options nosniff always;
    client_max_body_size 26M;

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

    location = /up { access_log off; }
    location = /ready { access_log off; }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_read_timeout 120;
    }

    location ~ /\.(?!well-known).* { deny all; }
    location ~* \.(?:css|js|jpg|jpeg|png|gif|svg|ico|woff2)$ {
        expires 7d;
        add_header Cache-Control "public, immutable";
        try_files $uri =404;
    }
}
