Welcome! Log In Create A New Profile

Advanced

Nginx showing 504 Gateway timed out when uploading large files

Posted by martinszeltins 
Nginx showing 504 Gateway timed out when uploading large files
February 23, 2021 07:41AM
I have a simple PHP file upload script that uploads a file. The server consists of 1 nginx reverse proxy and another nginx server (upstream). The problem is that when I try to upload very large files ~ 2GB then I get an error:

"504 Gateway Time-out"

Here is my reverse proxy configuration:

----------------------------------
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;
}
}
----------------------------------


And here is the other nginx server (upstream):

----------------------------------
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;
}
}
----------------------------------
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready