bookstack uploads and timeouts

to expand on from another bookstack post i made i wanted to share some of the things ive had to adjust to allow for seemingly normal operation to work with larger images and videos that are pretty common anymore.

to expand on from another bookstack post i made i wanted to share some of the things ive had to adjust to allow for seemingly normal operation to work with larger images and videos that are pretty common anymore.

Expanding upload capabilities

the confluence instance im replacing used to host training videos and quick little clips of things for people to know what to do. some of them were fairly large, and the default settings in the docker container do not allow for that. there are three locations to consider when tweaking upload capabilities and time outs. first, my setup - I have my bookstack container running behind an instance of nginx which has some settings to apply for things like this. Secondly, the thing to keep in mind is there is also another instance of nginx inside the LSIO container for bookstack, so you have to adjust settings there as well. Third would be the .env file for bookstack itself.

file locations

  • nginx in LSIO container - this is the location you have as your bind mount for the container, so "/mnt/containers/bookstack/config" would be where yo uconfigured in the docker-compose
    • /mnt/containers/bookstack/config/nginx/site-confs/default.conf
  • .env file - this is the location of the bind mount for the container similar to the container nginx
    • /mnt/containers/bookstack/config/www/.env
  • nginx in your own proxy in front of container - this location is going to vary depending on how you have nginx configured but typically will be in
    • /etc/nginx/default.conf
  • php settings - this one i mentioned in another post but i feel can most likely help with what we are trying to accomplish here too
    • /mnt/containers/bookstack/config/php/php-local.ini

Configure

main proxy server

Lets start with the flow of the web requests so that would be your public nginx if youre using one. In the default.conf or your included subdirectory file definition you'll want to set some limits for timeouts and max sizes. youll likely want to be careful with this so you dont kill your proxy server or open it to buffer attacks.

I added these two values inside of the server block definition. the client_max_body_size should allow for about 4gb of data

   client_max_body_size 4096m;
   client_body_timeout 460s;

the timeout was important because i found myself editing in the draw.io portion of a post for over two hours and then went to save and it lost all my changes when it failed to save the post. I had asked about this on the dev's discord and he said he was going to look into somehow caching the draw.io before trying to make the save. thats what i love about this confluence alternative, the dev is super responsive. Back to that timeout setting though, note this one down because we'll have to use it later.

The other point to keep in mind with the public proxy part of this is if youre using a cloudflare tunnel the upload of larger files just didnt seem to work and this is a limitation of cloudflare's free tunneling

bookstack config

all of these settings are documented on the bookstack documentation pages, but at the time of this writing these are the settings i used. these settings touch on the max sizes, caching, and session timeouts. ill let the comments and the bookstack documentation go more in depth but really these are the things that made the difference for me. without these i had difficulties uploading even a 50mb image to a page

# Maximum file size, in megabytes, that can be uploaded to the system.
FILE_UPLOAD_SIZE_LIMIT=4096

# Set both the cache and session to use Redis
CACHE_DRIVER=redis
SESSION_DRIVER=redis

# Example of using a single local Redis server
REDIS_SERVERS=redis:6379:0

# Session lifetime in minutes.
# Defaults to 120
SESSION_LIFETIME=460

the redis settings i believe are really for a much larger installation but i configured it on mine since i had a redis instance already and it did seem to help nextcloud quite a bit.

internal nginx

the LSIO container for bookstack runs its own nginx proxy. so if you remember those short moments ago where i said to note down that setting in your main proxy, those are the same settings that need applied here.

so in your config bind mount location, find this file

"/mnt/containers/bookstack/config/nginx/site-confs/default.conf"

and add those same settings we added to your main proxy server in front of this container

    client_max_body_size 4096m;
    client_body_timeout 460s;

cleanup

after youve got that all configured, you'll need to restart the docker container with a docker restart <yourBookstackContainerName> and then also have your public nginx in front of the container reload the config with a nginx -t to test the new config and if it works then run nginx -s reload. and youre done... if your page loads still. good luck troubleshooting if things didnt come back up!