Skip to main content

Bookstack Setup

Created new user called "bookstack" with homedir /home/bookstack/ and in the doockeer group.

compose.yml

---
services:
  bookstack:
    image: lscr.io/linuxserver/bookstack:25.02.5
    container_name: bookstack
    networks:
      - bookstack
    environment:
      - PUID=2001
      - PGID=2001
      - APP_URL=https://docs.craftidore.com/docs/
      - APP_KEY=base64:UhmRoapcSbIJO4rEpdc49vLoGl5jHwLmyOA1duMyIXg=
      - DB_HOST=bookstack_db
      - DB_PORT=3306
      - DB_USER=bookstack
      - DB_PASS=bookstack
      - DB_DATABASE=bookstack
    volumes:
      - ./bookstack_app_data:/config
    ports:
      - 6875:80
    restart: unless-stopped
    depends_on:
      - bookstack_db
  bookstack_db:
    image: lscr.io/linuxserver/mariadb:11.4.5
    container_name: bookstack_db
    networks:
      - bookstack
    environment:
      - PUID=2001
      - PGID=2001
      - MYSQL_ROOT_PASSWORD=B00kst4ck
      - TZ=America/Chicago
      - MYSQL_DATABASE=bookstack
      - MYSQL_USER=bookstack
      - MYSQL_PASSWORD=bookstack
    volumes:
      - ./bookstack_db_data:/config
    restart: unless-stopped

networks:
  bookstack:
    name: bookstack

Used the above docker compose. First, I had to acquire an app key via running this command:

docker run -it --rm --entrypoint /bin/bash lscr.io/linuxserver/bookstack:latest appkey

However, due to a bug(?) in linuxserver.io's bookstack container, the passwords I set were not being applied. Consequently, after booting up to let the directory structure get produced, I had to docker compose down and edit bookstack_app_data/www/.env to set the APP_KEY, APP_URL, DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD.

After that, bookstack ran correctly and connected to the database. 

To get it hooked up to nginx, I created a new enabled site (docs.craftidore.com) and used the following reverse proxy:

        location /docs {
                return 302 $scheme://$host/docs/;
        }

        location ~ ^/docs/(.*)$ {
                # Proxy main Bookstack traffic
                proxy_pass http://$bookstack:6875/$1$is_args$args;
                proxy_pass_request_headers on;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Host $http_host;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $http_connection;
        }

Using a non-regex proxy led to infinite loop redirects for some reason. I still don't know why.