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

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

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

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass app:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_buffer_size 32k;
        fastcgi_buffers 8 16k;
    }

    location ^~ /internal-docs/ {
        # Docusaurus static build lives in app-code volume at /var/www/html/docs/site/build
        alias /var/www/html/docs/site/build/;
        index index.html;
        try_files $uri $uri/ /internal-docs/index.html;

        auth_basic "Fotospiel Internal Docs";
        auth_basic_user_file /etc/nginx/.htpasswd-docs;

        add_header Cache-Control "private, no-store";
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|svg|webp|woff2?)$ {
        expires 30d;
        access_log off;
    }

    client_max_body_size 32m;
}
