Nginx 上传大文件时显示 504 网关超时

Nginx 上传大文件时显示 504 网关超时

我有一个简单的 PHP 文件上传脚本,用于上传文件。该服务器由 1 个 nginx 反向代理和另一个 nginx 服务器(上游)组成。问题是,当我尝试上传非常大的文件(约 2GB)时,会出现错误:

504网关超时

这是我的反向代理配置:

server {
    listen 80;
    
    server_name upload.mycloudhost.com;

    proxy_buffer_size 1024k;
    proxy_buffers 4 1024k;
    proxy_busy_buffers_size 1024k;
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
    client_body_timeout         600;
    client_header_timeout       600;
    keepalive_timeout           600;
    uwsgi_read_timeout          600;

    location / {
        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_pass http://localhost:13670;
    }
}

这是另一个 nginx 服务器(上游):

server {
    listen 80;
    
    server_name upload.mycloudhost.com;

    client_max_body_size 80G;
    proxy_buffer_size 1024k;
    proxy_buffers 4 1024k;
    proxy_busy_buffers_size 1024k;
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
    client_body_timeout         600;
    client_header_timeout       600;
    keepalive_timeout           600;
    uwsgi_read_timeout          600;

    root /var/www/mycloudhost;
    index index.php index.html index.htm index.nginx-debian.html;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location / {
        try_files $uri $uri/ =404;
    }
}

相关内容