Good morning,
I have a problem for some time that i don’t know how to solve.
From a Spring application i am trying to upload a file to the server.
Everything is fine, except when the file is larger than 200MB. There, the application returns a 413 .. sometimes simply
connection timeout..
The server is Centos 7 and there is Nginx underneath.
I tried running the client_max_body_size but it doesn’t matter.
Anyone know what the problem might be?
These are my configuration’s files
application.properties:
spring.servlet.multipart.maxFileSize=-1
spring.servlet.multipart.maxRequestSize=-1
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=-1
spring.servlet.multipart.max-request-size=-1
/etc/nginx/nginx.conf:
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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 3000;
gzip on;
include /etc/nginx/conf.d/*.conf;
client_max_body_size 500M;
server{
client_max_body_size 0;
location /upload {
client_max_body_size 500M;
return 201 $request_body_file;
}
location / {
client_max_body_size 500M;
}
}
}
/etc/php.ini:
max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 500M
post_max_size = 500M
memory_limit = 12000
2
Answers
Already done. I put client_max_body_size everywhere, but it has no effect
/etc/nginx:
nginx.conf:
Service:
systemctl restart nginx and systemctl reload nginx
Upload file greater a 200MB and: enter image description here
You need to change the Nginx server settings by modifying the file nginx.conf. Look for the directive client_max_body_size in this file and change the value (in megabytes) to the maximum file size you prefer. Save the file, and reload Nginx to see the change.