server {
    listen 80;
    server_name front.octave.immo.docker;

    # Redirection HTTP vers HTTPS
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name front.octave.immo.docker;

    # Configuration SSL
    ssl_certificate /usr/local/share/ca-certificates/front.octave.immo.docker.crt;
    ssl_certificate_key /usr/local/share/ca-certificates/front.octave.immo.docker.key;

    # Paramètres SSL sécurisés
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;

    root /var/www/html/apps/front/octave/fo/public;

    # Augmenter la limite de taille des uploads
    client_max_body_size 100M;

    index index.php;

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

    # Servir les fichiers PDF depuis storage/temp
    location /storage/temp/ {
        alias /var/www/html/apps/front/octave/fo/storage/app/public/temp/;
        access_log off;
        expires 1h;
        add_header Cache-Control "public, immutable";
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # Forward client and proxy info so Laravel can detect HTTPS
        fastcgi_param  HTTPS              $http_x_forwarded_proto;
        fastcgi_param  HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
        fastcgi_param  HTTP_X_FORWARDED_HOST  $http_host;
        fastcgi_param  HTTP_X_FORWARDED_PORT  $http_x_forwarded_port;

        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_read_timeout 120s;
    }
}

