possibility that the application work in a subdirectory of a site #42

Closed
opened 2026-02-04 16:19:15 +03:00 by OVERLORD · 24 comments
Owner

Originally created by @fibis on GitHub (Jan 4, 2016).

Originally created by @fibis on GitHub (Jan 4, 2016).
OVERLORD added the 🛠️ Enhancement label 2026-02-04 16:19:15 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 27, 2016):

Hi,
Sorry for combing back to this late. If I'm honest I'm a little wary of this one. Allowing subdirectory placement of BookStack has the side effect of making it easy to have all the app files within publicly accessible space thus opening it up to all kinds of possible security issues.

I'm sure there's ways around this with careful apache/nginx/other config editing but it would make things too easy to get wrong. At the moment the set-up somewhat forces you to have a more secure structure or at least makes you think about it.

I understand that it would make things easier for using on shared web services but these days decent VPS solutions are becoming very affordable so this is becoming less of an issue.

This is definitely technically possible to do, It's just my gut feeling is against it.

I will leave this issue open for discussion though so potential solutions/reasoning's can be added.

@ssddanbrown commented on GitHub (Feb 27, 2016): Hi, Sorry for combing back to this late. If I'm honest I'm a little wary of this one. Allowing subdirectory placement of BookStack has the side effect of making it easy to have all the app files within publicly accessible space thus opening it up to all kinds of possible security issues. I'm sure there's ways around this with careful apache/nginx/other config editing but it would make things too easy to get wrong. At the moment the set-up somewhat forces you to have a more secure structure or at least makes you think about it. I understand that it would make things easier for using on shared web services but these days decent VPS solutions are becoming very affordable so this is becoming less of an issue. This is definitely technically possible to do, It's just my gut feeling is against it. I will leave this issue open for discussion though so potential solutions/reasoning's can be added.
Author
Owner

@tpetrauskas commented on GitHub (Mar 26, 2016):

This would be definitely a security flow. The server administrator could use Apache2 aliases for that functionality (as phpMyAdmin is using by default).

@tpetrauskas commented on GitHub (Mar 26, 2016): This would be definitely a security flow. The server administrator could use [Apache2 aliases](https://httpd.apache.org/docs/current/mod/mod_alias.html) for that functionality (as phpMyAdmin is using by default).
Author
Owner

@chorsnell commented on GitHub (Aug 9, 2016):

Running into issues with a dockerised container, and nginx reverse proxy to put it on a sub directory. Loads but all the CSS / JS is pointing at the wrong place, and navigating anywhere breaks.

Tried with and without the rewrite rules, but doesn't seem to have any effect, any ideas?

upstream bookstack { server 127.0.0.1:8050; }
server {
  location    /docs/ {

    rewrite           ^/docs/$ http://bookstack/docs/ permanent;
    rewrite           ^/docs/(.*) /$1 break;
    proxy_pass  http://bookstack/docs/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $remote_addr;
  }
}
@chorsnell commented on GitHub (Aug 9, 2016): Running into issues with a dockerised container, and nginx reverse proxy to put it on a sub directory. Loads but all the CSS / JS is pointing at the wrong place, and navigating anywhere breaks. Tried with and without the rewrite rules, but doesn't seem to have any effect, any ideas? ``` upstream bookstack { server 127.0.0.1:8050; } server { location /docs/ { rewrite ^/docs/$ http://bookstack/docs/ permanent; rewrite ^/docs/(.*) /$1 break; proxy_pass http://bookstack/docs/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; } } ```
Author
Owner

@ssddanbrown commented on GitHub (Aug 9, 2016):

@poppahorse Yeah, Pretty much all links and assets are referenced as root relative. Need to go over all links and covert them to be app relative.

Since you've shown a good use case of using BookStack in a subdomain securely (Proxying to a docker container) I'll remove the 'Open to discussion' label and mark this as something to be done.

@ssddanbrown commented on GitHub (Aug 9, 2016): @poppahorse Yeah, Pretty much all links and assets are referenced as root relative. Need to go over all links and covert them to be app relative. Since you've shown a good use case of using BookStack in a subdomain securely (Proxying to a docker container) I'll remove the 'Open to discussion' label and mark this as something to be done.
Author
Owner

@chorsnell commented on GitHub (Aug 10, 2016):

Awesome thanks! I know this issue is an oldie, and dont want to sound pushy, but any idea of a rough timeline? 😛

Got 4 projects lined up that I'd love to use bookstack for, 2 of them fairly imminent 😃

@chorsnell commented on GitHub (Aug 10, 2016): Awesome thanks! I know this issue is an oldie, and dont want to sound pushy, but any idea of a rough timeline? :stuck_out_tongue: Got 4 projects lined up that I'd love to use bookstack for, 2 of them fairly imminent :smiley:
Author
Owner

@ssddanbrown commented on GitHub (Aug 11, 2016):

@poppahorse I was looking to do a bit of BookStack bug-bash session this weekend. If I have enough time I'll include this within the bug-bash.

@ssddanbrown commented on GitHub (Aug 11, 2016): @poppahorse I was looking to do a bit of BookStack bug-bash session this weekend. If I have enough time I'll include this within the bug-bash.
Author
Owner

@chorsnell commented on GitHub (Aug 11, 2016):

thanks, that would be great! for the prompt responses 👍

@chorsnell commented on GitHub (Aug 11, 2016): thanks, that would be great! for the prompt responses :+1:
Author
Owner

@ssddanbrown commented on GitHub (Aug 14, 2016):

Okay this should now be possible as of v0.11.1 that was just released. I'll add the process to the docs soon but, in general, you need to re-write the requests like in the example nginx config above and set the APP_URL param in the .env file to your full path.

There were quite a few areas in the app that were updated to allow this so there's a good chance I've missed a few changes. If you come across any links or redirects that don't include the extra path component just open a new issue.

@poppahorse I tested using pretty much the same nginx config as you posted but I proxied to another Nginx site. I have not yet tested it proxying to docker but I'm hoping it shouldn't be any different.

@ssddanbrown commented on GitHub (Aug 14, 2016): Okay this should now be possible as of v0.11.1 that was just released. I'll add the process to the docs soon but, in general, you need to re-write the requests like in the example nginx config above and set the `APP_URL` param in the `.env` file to your full path. There were [quite a few areas](https://github.com/ssddanbrown/BookStack/commit/43d9d2eba76528dc1bcaccb6896b110faa920cff?diff=split) in the app that were updated to allow this so there's a good chance I've missed a few changes. If you come across any links or redirects that don't include the extra path component just open a new issue. @poppahorse I tested using pretty much the same nginx config as you posted but I proxied to another Nginx site. I have not yet tested it proxying to docker but I'm hoping it shouldn't be any different.
Author
Owner

@chorsnell commented on GitHub (Aug 15, 2016):

thanks @ssddanbrown much appreciated on the quick turnaround, I will hopefully have time to have a play with this later today, will let you know how it goes.

@chorsnell commented on GitHub (Aug 15, 2016): thanks @ssddanbrown much appreciated on the quick turnaround, I will hopefully have time to have a play with this later today, will let you know how it goes.
Author
Owner

@chorsnell commented on GitHub (Aug 18, 2016):

So I have discovered a few places where the baseUrl is required, I made a PR for the initial login one, but how would you prefer the others? In here?

Also how does it save / store the Application name field and settings like primary color? Managed to get 2 copies up and running at:

http://domain/docs/project
http://domain/docs/project2

But despite them having their own database, they seem to share those settings. Any ideas? :)

@chorsnell commented on GitHub (Aug 18, 2016): So I have discovered a few places where the baseUrl is required, I made a PR for the initial login one, but how would you prefer the others? In here? Also how does it save / store the `Application name` field and settings like primary color? Managed to get 2 copies up and running at: http://domain/docs/project http://domain/docs/project2 But despite them having their own database, they seem to share those settings. Any ideas? :)
Author
Owner

@ssddanbrown commented on GitHub (Aug 18, 2016):

@poppahorse List any additional url's in the comments of the pull request. I'll go through this weekend and send out another bugfix release to implement them.

Application settings are saved in the database and are also cached. Could the cache be shared across both in your setup? By default it's stored in the application storage folder unless you've set up memcached or redis.

@ssddanbrown commented on GitHub (Aug 18, 2016): @poppahorse List any additional url's in the comments of the pull request. I'll go through this weekend and send out another bugfix release to implement them. Application settings are saved in the database and are also cached. Could the cache be shared across both in your setup? By default it's stored in the application `storage` folder unless you've set up memcached or redis.
Author
Owner

@chorsnell commented on GitHub (Aug 18, 2016):

Will do on the other URLs, thanks :)

And cool, that makes sense re: cache. I will have a play!

@chorsnell commented on GitHub (Aug 18, 2016): Will do on the other URLs, thanks :) And cool, that makes sense re: cache. I will have a play!
Author
Owner

@montharon commented on GitHub (Aug 20, 2016):

I'm currently also struggling the get BookStack running on my RaspberryPi.
I have other different webfolders (for instance baikal, grav, mediawiki) running on my NGINX server.
Therefore, I will have to use BookStack in it's separate subfolder on my public root.
I have tried various configurations of my NGINX default config to get BookStack running and I also did change the .env setting to http://192.168.0.12/subfolder, but without any luck ;(

@poppahorse
Do you have a running version of your NGINX config for me ;)
I just wanted to have BookStack running in its own subfolder, for instance /bookstack
and redirect all incoming request on that url to /bookstack/public

Is there already a version that can be installed in a subfolder?
I have cloned the latest release from github...

Many thanks and advance and @ssddanbrown keep up the great work!
montharon

@montharon commented on GitHub (Aug 20, 2016): I'm currently also struggling the get BookStack running on my RaspberryPi. I have other different webfolders (for instance baikal, grav, mediawiki) running on my NGINX server. Therefore, I will have to use BookStack in it's separate subfolder on my public root. I have tried various configurations of my NGINX default config to get BookStack running and I also did change the .env setting to http://192.168.0.12/subfolder, but without any luck ;( @poppahorse Do you have a running version of your NGINX config for me ;) I just wanted to have BookStack running in its own subfolder, for instance /bookstack and redirect all incoming request on that url to /bookstack/public Is there already a version that can be installed in a subfolder? I have cloned the latest release from github... Many thanks and advance and @ssddanbrown keep up the great work! montharon
Author
Owner

@ssddanbrown commented on GitHub (Aug 20, 2016):

@montharon Thanks!

I do not recommend installing BookStack within an actual subfolder as it can expose a lot of files which should not be publically accessible. The latest version (v0.11.1) allows you to install BookStack on a URL sub-path (Such as http://domain.com/bookstack) but this should be done via proxying.

I will update the docs with this soon but for now I have created a gist with the nginx config I used to test this. This can be found here. I have commented it up so hopefully you can follow it okay. Will take a little nginx experience. Give me a shout if you have any issues.

@ssddanbrown commented on GitHub (Aug 20, 2016): @montharon Thanks! I do not recommend installing BookStack within an actual subfolder as it can expose a lot of files which should not be publically accessible. The latest version (v0.11.1) allows you to install BookStack on a URL sub-path (Such as http://domain.com/bookstack) but this should be done via proxying. I will update the docs with this soon but for now I have created a gist with the nginx config I used to test this. [This can be found here](https://gist.github.com/ssddanbrown/0d5fdecc0e7370a1fbc3f7e2f2f1a189). I have commented it up so hopefully you can follow it okay. Will take a little nginx experience. Give me a shout if you have any issues.
Author
Owner

@montharon commented on GitHub (Aug 20, 2016):

@ssddanbrown
Many, many thanks for your quick reply!

According to your suggested gist I changed my config to the following:

My NGINX default config

Unfortunately this does not work either, since every request is automatically redirected to
192.168.0.12/login

Any suggestions?

Many thanks in advance,
montharon

@montharon commented on GitHub (Aug 20, 2016): @ssddanbrown Many, many thanks for your quick reply! According to your suggested gist I changed my config to the following: [My NGINX default config](https://gist.github.com/montharon/3d0376c991c567b4cd7e3c759df8fee5) Unfortunately this does not work either, since every request is automatically redirected to 192.168.0.12/login Any suggestions? Many thanks in advance, montharon
Author
Owner

@ssddanbrown commented on GitHub (Aug 20, 2016):

@montharon Have you set the APP_URL param in the BookStack .env file to be your desired url? I forgot to mention that in my post above.

@ssddanbrown commented on GitHub (Aug 20, 2016): @montharon Have you set the `APP_URL` param in the BookStack `.env` file to be your desired url? I forgot to mention that in my post above.
Author
Owner

@montharon commented on GitHub (Aug 20, 2016):

@ssddanbrown
I have set the APP_URL in the .env file to
http://192.168.0.12/bs

@montharon commented on GitHub (Aug 20, 2016): @ssddanbrown I have set the APP_URL in the .env file to http://192.168.0.12/bs
Author
Owner

@ssddanbrown commented on GitHub (Aug 20, 2016):

@montharon Okay, It might not be to do with your setup then, Could be #166 at play here. Planning to send another bugfix release out tomorrow to cover that.

@ssddanbrown commented on GitHub (Aug 20, 2016): @montharon Okay, It might not be to do with your setup then, Could be #166 at play here. Planning to send another bugfix release out tomorrow to cover that.
Author
Owner

@montharon commented on GitHub (Aug 20, 2016):

@ssddanbrown Wow, that's good news! Your support and work is much appreciated!

@montharon commented on GitHub (Aug 20, 2016): @ssddanbrown Wow, that's good news! Your support and work is much appreciated!
Author
Owner

@ssddanbrown commented on GitHub (Aug 21, 2016):

@montharon I've just published a new release. Give that a try and let me know how it goes.

@ssddanbrown commented on GitHub (Aug 21, 2016): @montharon I've just published a [new release](https://github.com/ssddanbrown/BookStack/releases/tag/v0.11.2). Give that a try and let me know how it goes.
Author
Owner

@montharon commented on GitHub (Aug 21, 2016):

@ssddanbrown Many, many thanks to you Dan! Now it works like a charme ;)
The only thing that I figured out that it's not possible to export a page as PDF file.

The auto-generated URL looks like this:
http://192.168.0.12/docs/books/book01/page/page01/export/pdf

Cheers,
montharon

@montharon commented on GitHub (Aug 21, 2016): @ssddanbrown Many, many thanks to you Dan! Now it works like a charme ;) The only thing that I figured out that it's not possible to export a page as PDF file. The auto-generated URL looks like this: `http://192.168.0.12/docs/books/book01/page/page01/export/pdf` Cheers, montharon
Author
Owner

@ssddanbrown commented on GitHub (Aug 21, 2016):

Hey @montharon, Glad its now working. That PDF export link looks correct & PDF exports are working okay for me, What's the issue you're getting? Info about viewing error output can be found here.

@ssddanbrown commented on GitHub (Aug 21, 2016): Hey @montharon, Glad its now working. That PDF export link looks correct & PDF exports are working okay for me, What's the issue you're getting? Info about viewing error output can be found [here](https://www.bookstackapp.com/docs/admin/debugging).
Author
Owner

@montharon commented on GitHub (Aug 21, 2016):

@ssddanbrown Hmmmm, set the debugging to true in the .env file and exported a page...
No errors, but a blank page and nothing to download.
Checked the naravel.log also, but found nothing special or unexpected...

@montharon commented on GitHub (Aug 21, 2016): @ssddanbrown Hmmmm, set the debugging to true in the .env file and exported a page... No errors, but a blank page and nothing to download. Checked the naravel.log also, but found nothing special or unexpected...
Author
Owner

@minecraftchest1 commented on GitHub (Jul 2, 2021):

I have just installed BookStack on my pi with a symlink from /opt/BookStack/public to /var/www/html/bookstack. I was able to access the long page, but then I got a ERR_TOO_MANY_REDIRECTS error.
image

@minecraftchest1 commented on GitHub (Jul 2, 2021): I have just installed BookStack on my pi with a symlink from /opt/BookStack/public to /var/www/html/bookstack. I was able to access the long page, but then I got a ERR_TOO_MANY_REDIRECTS error. ![image](https://user-images.githubusercontent.com/42992675/124191954-2a99da00-da8a-11eb-8e14-7e94c2dbd88a.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#42