# docker/nginx/default.conf

# HTTP → HTTPS


server {
    listen 80;
    server_name mareike.local;

    ssl_certificate     /etc/nginx/certs/mareike.local.pem;
    ssl_certificate_key /etc/nginx/certs/mareike.local-key.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers off;

    root /var/www/html/public;
    index index.php;

    # Logging
    access_log /var/log/nginx/mareike.access.log combined;
    error_log /var/log/nginx/mareike.error.log warn;

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

    location ~ \.php$ {
            include fastcgi_params;
            fastcgi_pass mareike-app:9000;  # Containername vom PHP-FPM
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # In der Nginx-Konfiguration von mareike.local
    location /build/assets/ {
        # Erlaubt explizit deine Subdomain
        add_header 'Access-Control-Allow-Origin' "$http_origin" always;
        add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
        add_header 'Access-Control-Allow-Headers' 'Content-Type, X-Inertia' always;

        # Falls du alle Subdomains von mareike.local erlauben willst:
        #
    }
}

