server {
    listen 0.0.0.0:80;
    root /var/www/html;
    server_name localhost;

    location / {
        index index.php index.html;
        try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass php:9000;
        include /etc/nginx/fastcgi_params;        
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO  $fastcgi_path_info;
        
        # Ajustes para tiempos de espera largos
        fastcgi_read_timeout 1000;   # Aumentar tiempo de espera para lectura
        fastcgi_send_timeout 1000;   # Aumentar tiempo de espera para enviar datos
        proxy_read_timeout 1000;     # Aumentar tiempo de espera para proxy
        proxy_connect_timeout 1000;  # Aumentar tiempo de conexión
    }

    location ^~ /css {
        add_header  Content-Type    text/css;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_hide_header X-Powered-By;
    }

    location ^~ /js {
        add_header  Content-Type    application/javascript;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_hide_header X-Powered-By;
    }
}
