Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fibis opened this issue Jan 4, 2016 · 24 comments
Closed

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

fibis opened this issue Jan 4, 2016 · 24 comments

Comments

@fibis
Copy link

fibis commented Jan 4, 2016

No description provided.

@ssddanbrown
Copy link
Member

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.

@tpetrauskas
Copy link

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

@chorsnell
Copy link
Contributor

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;
  }
}

@ssddanbrown
Copy link
Member

@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.

@chorsnell
Copy link
Contributor

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 😃

@ssddanbrown
Copy link
Member

@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.

@chorsnell
Copy link
Contributor

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

@ssddanbrown
Copy link
Member

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.

@chorsnell
Copy link
Contributor

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
Copy link
Contributor

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? :)

@ssddanbrown
Copy link
Member

@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.

@chorsnell
Copy link
Contributor

Will do on the other URLs, thanks :)

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

@montharon
Copy link

montharon commented 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

@ssddanbrown
Copy link
Member

@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.

@montharon
Copy link

@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

@ssddanbrown
Copy link
Member

@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.

@montharon
Copy link

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

@ssddanbrown
Copy link
Member

@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.

@montharon
Copy link

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

@ssddanbrown
Copy link
Member

ssddanbrown commented Aug 21, 2016

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

@montharon
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants