server {
    listen 0.0.0.0:80;  # Écouter sur toutes les interfaces réseau (IPv4)

    # Répertoire de travail de Nginx
    root /var/www/html;
    index index.php index.html;

    # Gestion des fichiers PHP avec le socket Unix
    location ~ \.php$ {
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        
        # Paramètre de chemin de fichier pour le traitement PHP
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $document_root;

        # Inclure les paramètres FastCGI standard
        include fastcgi_params;
    }

    # Serveur de fichiers statiques (images, CSS, JS, etc.)
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    # Gestion du favicon
    location = /favicon.ico {
        root /var/www/html;
    }

    # Gestion des erreurs 404
    error_page 404 /404.html;
    location = /404.html {
        root /usr/share/nginx/html;
    }
}