Link to a full Apache virtualhost example in docs #2324

Closed
opened 2026-02-05 03:40:08 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @gaelanlloyd on GitHub (Jul 18, 2021).

Describe the bug
When following the official install instructions and doing a fresh install on Debian or Alpine Linux, these specific rewrite rules lead to a "400 Bad Request" error in your browser.

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

If I comment out that section in the virtualhost and reload Apache, Bookstack loads without a problem.

Steps To Reproduce

  1. Do a fresh install, following all the steps.
  2. Add in the virtualhost declarations from the official install page.
  3. Navigate to the Bookstack web interface, get a "400 Bad Request" error.

Expected behavior
You see the Bookstack web interface instead of the error.

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): Can't access to see, but it's the latest from installs done today (2021-07-17).
  • PHP Version: 7.3.29
  • Hosting Method (Nginx/Apache/Docker): Latest versions of Apache on Alpine Linux and Debian 10 stable.

Here's my Apache virtualhost file:

<VirtualHost *:80>

    ServerName bookstack.testserver.com

    DocumentRoot /var/www/bookstack/public

    DirectoryIndex index.php index.html index.htm

    <Directory /var/www/bookstack/public>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</VirtualHost>
Originally created by @gaelanlloyd on GitHub (Jul 18, 2021). **Describe the bug** When following the [official install instructions](https://www.bookstackapp.com/docs/admin/installation/) and doing a fresh install on Debian or Alpine Linux, these specific rewrite rules lead to a "400 Bad Request" error in your browser. ``` # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] ``` If I comment out that section in the virtualhost and reload Apache, Bookstack loads without a problem. **Steps To Reproduce** 1. Do a fresh install, following all the steps. 2. Add in the virtualhost declarations from the official install page. 3. Navigate to the Bookstack web interface, get a "400 Bad Request" error. **Expected behavior** You see the Bookstack web interface instead of the error. **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): Can't access to see, but it's the latest from installs done today (2021-07-17). - PHP Version: 7.3.29 - Hosting Method (Nginx/Apache/Docker): Latest versions of Apache on Alpine Linux and Debian 10 stable. Here's my Apache virtualhost file: ``` <VirtualHost *:80> ServerName bookstack.testserver.com DocumentRoot /var/www/bookstack/public DirectoryIndex index.php index.html index.htm <Directory /var/www/bookstack/public> Options FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Send Requests To Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </VirtualHost> ```
OVERLORD added the 📖 Docs Update label 2026-02-05 03:40:08 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jul 18, 2021):

Hi @gaelanlloyd,
I don't think there's a particular issue with those lines, We use the same rules in the install script (https://github.com/BookStackApp/devops/blob/master/scripts/installation-ubuntu-20.04.sh#L103-L106) that has been used many times.

It might be the case these need to be added within the directory block to work as intended? Alternatively this might be due to the AllowOverride All in your config, There could be a conflict with this virtualhost content and any existing .htaccess files. I'd advise disabling AllowOverride None instead since you've got full control of the Apache config.

@ssddanbrown commented on GitHub (Jul 18, 2021): Hi @gaelanlloyd, I don't think there's a particular issue with those lines, We use the same rules in the install script (https://github.com/BookStackApp/devops/blob/master/scripts/installation-ubuntu-20.04.sh#L103-L106) that has been used many times. It might be the case these need to be added within the directory block to work as intended? Alternatively this might be due to the `AllowOverride All` in your config, There could be a conflict with this virtualhost content and any existing `.htaccess` files. I'd advise disabling `AllowOverride None` instead since you've got full control of the Apache config.
Author
Owner

@gaelanlloyd commented on GitHub (Jul 19, 2021):

Hi Dan, thanks for writing back so quickly. You're correct, moving those sections into the directory block did the trick!

I was just thinking, linking to a complete Apache virtualhost file in the Bookstack manual install instructions would be really handy for newbies like me. The one in the install script you linked to would be perfect. I was stuck on this for an embarrassingly long amount of time and couldn't figure out what the issue was.

@gaelanlloyd commented on GitHub (Jul 19, 2021): Hi Dan, thanks for writing back so quickly. You're correct, moving those sections into the directory block did the trick! I was just thinking, linking to a complete Apache virtualhost file in the Bookstack manual install instructions would be really handy for newbies like me. The one in the install script you linked to would be perfect. I was stuck on this for an embarrassingly long amount of time and couldn't figure out what the issue was.
Author
Owner

@ssddanbrown commented on GitHub (Sep 29, 2021):

Thanks for the suggestion @gaelanlloyd.

I've now updated our installation instructions to lead to example webserver configurations instead of just showing limited snippets for redirects.

@ssddanbrown commented on GitHub (Sep 29, 2021): Thanks for the suggestion @gaelanlloyd. I've now updated our [installation instructions](https://www.bookstackapp.com/docs/admin/installation/) to lead to example webserver configurations instead of just showing limited snippets for redirects.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2324