server {
    listen 80;
    server_name _;
    root /var/www/html/public;
    index index.php;

    # Lesson videos / PDFs are uploaded through the app (see docs/DEPLOYMENT.md > Upload limits).
    # Keep this >= INFOTICS_VIDEO_MAX_MB and >= PHP post_max_size in infra/docker/php-uploads.ini.
    client_max_body_size 610m;
    client_body_timeout 300s;
    fastcgi_read_timeout 300s;

    gzip on;
    gzip_comp_level 5;
    gzip_min_length 1024;
    gzip_types text/css application/javascript application/json image/svg+xml application/xml text/plain;

    add_header X-Content-Type-Options nosniff always;
    add_header X-Frame-Options SAMEORIGIN always;
    add_header Referrer-Policy strict-origin-when-cross-origin always;

    # Static assets: far-future caching (URLs carry ?v=<mtime>).
    location ^~ /assets/ {
        expires 30d;
        add_header Cache-Control "public, max-age=2592000, immutable";
        try_files $uri =404;
    }

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

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT /var/www/html/public;
        fastcgi_pass app:9000;
    }

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