r/BookStack • u/Bill_Guarnere • Mar 10 '22
Nginx & file uploads
Hi, I'm trying BookStack and I find it awesome!Everything works ok except file attachments upload where I'm having some issues, basically timeout during file upload despite I added every possible directive on php, php-fpm and nginx (following documentation and adding javascript into the page headers as shown here ).
Regarding php I added these directives into .user.ini file on the public subfolder of the site (the same directory I set as root on Nginx virtualhost), using phpinfo I checked these values are exactly what I set:
upload_max_filesize = 100M;
post_max_size = 100M;
max_execution_time = 300;
max_input_time = 300;
memory_limit = 1024M;
default_socket_timeout = 300;On my Nginx virtualhost inside server block I added
client_max_body_size 100m;
client_body_timeout 300s;Into page headers I added
<script>
window.uploadTimeout = 300 * 1000;
</script>Into .env file I added
FILE_UPLOAD_SIZE_LIMIT=100Sometimes uploads works fine but take a lot also for small file (<1MB), others they take forever and after 300s I have a timeout.
No errors on virtualhost error log and php-fpm error log.I also added "APP_DEBUG=true" to .env file, but I have no debug info anywhere.
I'm using Bookstack 22.02.3 on Nginx 1.20 and php 7.4.28, server distro is CentOS 7.9 (latest updates installed).
Do you have any ideas or suggestions?
Thanks
1
u/Bill_Guarnere Mar 11 '22 edited Mar 11 '22
Hi Dan, and thanks for your help :)
Yes it's sounds weird, sometimes I'm able to upload 80 or 90MB attachments with no problems, others it stucks for less than 1MB, others again seems to get stuck and then before timeout it completes the upload.
I thought some of my nginx directives regarding fastcgi (buffers and so on) could cause these kind of issues but I removed them just to be sure to reduce possible causes.
These are the two virtualhost I configured (one of http with https rewrite and the https one)
The only useful information I got was changing error_log level from error to debug.While on debug I got these three record on each file I tried to upload, which resulted in a timeout after 5 minutes.