I spent so much time trying to sort this out, it's ridiculous...
I need to upload files up to 15Gb.
nginx.conf:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 800s;
include /etc/nginx/conf.d/*.conf;
}
Custom nginx conf
server {
listen 80;
listen [::]:80;
server_name example.com;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
if ($http_x_forwarded_proto != "https") {
rewrite ^(.*)$ https://$server_name$REQUEST_URI permanent;
}
root /var/www/webroot;
index index.php;
client_body_timeout 800s;
client_header_timeout 800s;
client_max_body_size 15000m;
client_body_temp_path /store/nginx-tmp 1 2;
#fastcgi_buffers 8 1600k;
#fastcgi_buffer_size 3200k;
add_header X-Frame-Options sameorigin;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass web:9000;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_connect_timeout 800s;
fastcgi_read_timeout 800s;
fastcgi_send_timeout 800s;
#proxy_connect_timeout 800s;
#proxy_send_timeout 800s;
#proxy_read_timeout 800s;
#send_timeout 800s;
}
}
The commented lines are additional configs I tried.
I added client_body_temp_path /store/nginx-tmp 1 2;
for Nginx to use a mounted volume to store temp files if needed because the EC2 instance only has a 8Gb disk.
Relevant PHP config:
upload_max_filesize = 15000M
post_max_size = 15000M
max_execution_time = 0
request_terminate_timeout = 800s
I am running a CakePHP application, in case that helps cracking this case.
When I upload a large file, I get a 504 after 2 to 2.5 minutes. The upload in incomplete ($_FILES['file']['error'] = 3, UPLOAD_ERR_PARTIAL)
There nothing in the PHP logs. Nginx logs only has this:
2020/04/17 06:38:04 [warn] 479#479: *943 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000007, client: 172.31.20.155, server: example.com, request: "POST /materials/add/38999 HTTP/1.1", host: "example.com", referrer: "https://example.com/jobs/view/38999"
Can anyone save my sanity here?
Thanks,