mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-02-07 03:09:44 +03:00
Use relative paths rather than absolute / Support mulitple base URLs or domains #1099
Open
opened 2026-02-04 23:45:19 +03:00 by OVERLORD
·
35 comments
No Branch/Tag Specified
development
further_theme_development
l10n_development
release
llm_only
vectors
v25-11
docker_env
drawio_rendering
user_permissions
ldap_host_failover
svg_image
prosemirror
captcha_example
fix/video-export
v25.12.3
v25.12.2
v25.12.1
v25.12
v25.11.6
v25.11.5
v25.11.4
v24.11.4
v25.11.3
v25.11.2
v25.11.1
v25.11
v25.07.3
v25.07.2
v25.07.1
v25.07
v25.05.2
v25.05.1
v25.05
v25.02.5
v25.02.4
v25.02.3
v25.02.2
v25.02.1
v25.02
v24.12.1
v24.12
v24.10.3
v24.10.2
v24.10.1
v24.10
v24.05.4
v24.05.3
v24.05.2
v24.05.1
v24.05
v24.02.3
v24.02.2
v24.02.1
v24.02
v23.12.3
v23.12.2
v23.12.1
v23.12
v23.10.4
v23.10.3
v23.10.2
v23.10.1
v23.10
v23.08.3
v23.08.2
v23.08.1
v23.08
v23.06.2
v23.06.1
v23.06
v23.05.2
v23.05.1
v23.05
v23.02.3
v23.02.2
v23.02.1
v23.02
v23.01.1
v23.01
v22.11.1
v22.11
v22.10.2
v22.10.1
v22.10
v22.09.1
v22.09
v22.07.3
v22.07.2
v22.07.1
v22.07
v22.06.2
v22.06.1
v22.06
v22.04.2
v22.04.1
v22.04
v22.03.1
v22.03
v22.02.3
v22.02.2
v22.02.1
v22.02
v21.12.5
v21.12.4
v21.12.3
v21.12.2
v21.12.1
v21.12
v21.11.3
v21.11.2
v21.11.1
v21.11
v21.10.3
v21.10.2
v21.10.1
v21.10
v21.08.6
v21.08.5
v21.08.4
v21.08.3
v21.08.2
v21.08.1
v21.08
v21.05.4
v21.05.3
v21.05.2
v21.05.1
v21.05
v21.04.6
v21.04.5
v21.04.4
v21.04.3
v21.04.2
v21.04.1
v21.04
v0.31.8
v0.31.7
v0.31.6
v0.31.5
v0.31.4
v0.31.3
v0.31.2
v0.31.1
v0.31.0
v0.30.7
v0.30.6
v0.30.5
v0.30.4
v0.30.3
v0.30.2
v0.30.1
v0.30.0
v0.29.3
v0.29.2
v0.29.1
v0.29.0
v0.28.3
v0.28.2
v0.28.1
v0.28.0
v0.27.5
v0.27.4
v0.27.3
v0.27.2
v0.27.1
v0.27
v0.26.4
v0.26.3
v0.26.2
v0.26.1
v0.26.0
v0.25.5
v0.25.4
v0.25.3
v0.25.2
v0.25.1
v0.25.0
v0.24.3
v0.24.2
v0.24.1
v0.24.0
v0.23.2
v0.23.1
v0.23.0
v0.22.0
v0.21.0
v0.20.3
v0.20.2
v0.20.1
v0.20.0
v0.19.0
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.3
v0.15.2
v0.15.1
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.2
v0.12.1
v0.12.0
v0.11.2
v0.11.1
v0.11.0
v0.10.0
v0.9.3
v0.9.2
v0.9.1
v0.9.0
v0.8.2
v0.8.1
v0.8.0
v0.7.6
v0.7.5
v0.7.4
v0.7.3
0.7.2
v.0.7.1
v0.7.0
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
Labels
Clear labels
🎨 Design
📖 Docs Update
🐛 Bug
🐛 Bug
:cat2:🐈 Possible duplicate
💿 Database
☕ Open to discussion
💻 Front-End
🐕 Support
🚪 Authentication
🌍 Translations
🔌 API Task
🏭 Back-End
⛲ Upstream
🔨 Feature Request
🛠️ Enhancement
🛠️ Enhancement
🛠️ Enhancement
❤️ Happy feedback
🔒 Security
🔍 Pending Validation
💆 UX
📝 WYSIWYG Editor
🌔 Out of scope
🔩 API Request
:octocat: Admin/Meta
🖌️ View Customization
❓ Question
🚀 Priority
🛡️ Blocked
🚚 Export System
♿ A11y
🔧 Maintenance
> Markdown Editor
pull-request
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/BookStack#1099
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Amolith on GitHub (Mar 20, 2019).
Describe the bug
It would be better to use relative paths than absolute. This issue is different from #1137 because I'm saying that everything should be relative rather than hardcoded. I'm trying to serve my BookStack instance over Tor and, even though it's served fine over the initial onion URL, every single link on the first page is to the clearnet site. I can manually enter the path to the onion URL and it works fine so it's simply an issue of hardcoded URLs vs relative.
Steps To Reproduce
Expected behavior
Screenshots

Your Configuration (please complete the following information):
@ssddanbrown commented on GitHub (Mar 20, 2019):
Thanks for the request.
This is related to #1310 and #1275 and #1137
@recklessnl commented on GitHub (Aug 28, 2019):
@ssddanbrown Has there been any progress on this issue yet? Still really annoying not being able to access local data on a local server if your internet goes out, without restarting the whole bookstack instance and messing with the local config files.
@AlphaJack commented on GitHub (Sep 10, 2019):
So far BookStack is the only app in my selfhosted server that I can't access from my LAN IP. To access I'm forced to:
It would be great to set APP_URL=/wiki/ to get it working on both the external and the internal IPs, but if I set so it redirects me to http:/192.168.1.13/wiki/wiki/wiki or https://example.com/wiki/wiki/wiki
@recklessnl commented on GitHub (Sep 10, 2019):
Same here - Bookstack is only app that is not modern enough to be able to handle this.
Ideally you could just reverse proxy it without messing with APP_URL settings and just let it live locally in order to work with a reverse proxy. Every other app I have tested work fine with a reverse proxy, except this one.
@AlphaJack commented on GitHub (Sep 21, 2019):
I thought I got it working by setting
in the
.envfile.URL would look like
and will resolve for every host, being it a LAN IP or a registered domain.
The point is, it only works for
/wiki/ (my location)
/wiki/shelves
/wiki/books
/wiki/register
/wiki/login (it works)
Going to /wiki/books/bookname or /wiki/user/n° will result in errors regarding the javascript files
I decided to try this after seeing that all the URLs in the "relative-urls" branch of IrosTheBeggar/mStream were starting with a dot (only this branch makes mStream also work in /locations/ and not only subdomains. )
@recklessnl commented on GitHub (Jan 31, 2020):
So is the above workaround by @AlphaJack suffice or is an actual fix coming for this @ssddanbrown? It's odd that bookstack still doesn't support both local IPs and domain names, I can't think of another selfhosted app that doesn't support it other than bookstack.
@recklessnl commented on GitHub (Feb 28, 2020):
pinging @ssddanbrown - major feature request that hopefully is already in the works.
@ssddanbrown commented on GitHub (Feb 29, 2020):
The way I see it: The actual goal/feature being request here is "Have the ability to host a single BookStack instance at multiple base URLs". Relative paths is just an implementation idea for that feature/goal.
I've found myself grow further against the idea of having relative or dynamic URLs due to the edge-cases or complexities they'd introduce. I'd be happy to explore other potential avenues depending on their level of interruption relative to the rest of the codebase & their maintenance cost.
I've just spent a few hours seeing if this can be done via nginx. You can achieve almost fully-functional support by setting up a proxy for the secondary base URL, leading to the primary, which uses
sub_filterandproxy_redirectto rewrite the urls for the most part. Unfortunately there are content issues when updating page content, since the POST body won't be re-written. Probably possible but quickly gets complicated due to body encoding and regex, tried but gave up on that route. Here's an example config I used, might be useful if your secondary base domain can be a read-only setup:(My primary domain was
http://bookstack.localand the secondary washttp://bookstack.local:88)@recklessnl For your specific setup, if you're intending to access that local instance from a single computer, you could just fix the DNS record to point locally. Alternatively, if you self-host/manage the DNS for local network you could add a rule there.
@disconsented commented on GitHub (Jun 22, 2020):
Would you be able to give some examples of this? I was under the impression that relative URLs are generally safe and are considered best practice.
@Deicid commented on GitHub (Sep 22, 2021):
I have the exact same problem. I'm surprised the developer couldn't fix it in two years.
It's the best product I've seen, but it's very hard to use without local access.
@gagnieremaxime commented on GitHub (Sep 29, 2021):
Hi, i had the same problem but i fixed it by running the bookstack container 2 times while connecting to the same db and the same config directory. Here is my docker-compose.yml file:
@Deicid commented on GitHub (Sep 29, 2021):
@gagnieremaxime Thank you for your message!
I set up a connection of two instances to the same database and I had problems with the pictures, their paths are broken. And the images downloaded from the local copy of Bookstack were not displayed in the external access (public version).
I don't know how this can be overcome
@gagnieremaxime commented on GitHub (Sep 29, 2021):
@Deicid it seems to work for me, could you show me your docker-compose.yml file?
@ssddanbrown commented on GitHub (Sep 29, 2021):
Just to confirm @gagnieremaxime, @Deicid is correct that there will be issues with content; At least where one URL cannot be accessed when using the other. It could work for some cases (Where one host is used read-only and has access to the other) but for most cases you'll end up with a mix of URLs used in content.
@gagnieremaxime commented on GitHub (Sep 29, 2021):
@ssddanbrown I had that happen on my first try, but right now I can access bookstack both at my domain and the local IP. Both can connect and upload images.
@ssddanbrown commented on GitHub (Sep 29, 2021):
@gagnieremaxime Sure, but it's not a matter of container configuration; It's a matter of networking. It's not a solution for everyone (An image upload & use via local only IP address will likely break upon page view from outside the local network).
@gagnieremaxime commented on GitHub (Sep 29, 2021):
@ssddanbrown You are right, I was looking at the books background to verify if upload was working, but in the page itself uploading an image kind of break it... Thank you for explaining
@jorfigfl commented on GitHub (May 13, 2022):
Hi! any update about this? We have the same issue, We have an internal domain for internal users (bookstack.domain1.com), and we are looking for an external url(bookname.domain2.net or domain2.net/doc/) to display the public documents only. Exist any solution or workaround?
@ssddanbrown commented on GitHub (May 13, 2022):
@jorfigfl No update, BookStack still only supports a being hosted on a single domain. You could look to use the export functions and/or API to create an external site from your public content.
@disconsented commented on GitHub (May 16, 2022):
For anyone who's handy with SQL, you can work around this by rewriting the URLs in the database to remove the domain.
@reytechsam commented on GitHub (Jun 8, 2022):
Would this work if we rewrite all the database url's? Has someone tried this before?
We have the same issue unfortunately.
@reytechsam commented on GitHub (Jun 8, 2022):
Okay, I think we got it working for our case:
Just edited nano /var/www/wiki/app/Config/app.php
and replaced this line :
'url' => env('APP_URL', '') === 'http://bookstack.dev' ? '' : env('APP_URL', ''),
with this one:
'url' => "https://" . $_SERVER['SERVER_NAME'] . "/wiki",
Note, it will brake with the next update, so keep a wiki with all your changes you made
@ssddanbrown commented on GitHub (Jun 8, 2022):
Just to confirm, the above methods are not supported and can cause issues during updates.
My comment here applies to the above, in that this will falter in scenarios where the URLs have different availability/access conditions.
In addition, the
APP_URLis used in more locations than just one file.@ani-6 commented on GitHub (Feb 13, 2024):
Any update on this issue?
@sunnyzhong812 commented on GitHub (May 28, 2024):
If used Apache, can refer to the following information.
https://www.liquidweb.com/kb/configure-apache-virtual-hosts-ubuntu-18-04/
@Stefansen commented on GitHub (Jun 28, 2024):
Any update on this issue?
@jdrusso commented on GitHub (Dec 11, 2024):
checking in 5 years later, still relevant and would still be great to get this
I need to expose services both on a local domain and a public-facing domain
@LordWiseRus commented on GitHub (Jan 26, 2025):
Hi! We need this feature. Please add it.
@alexisfrjp commented on GitHub (Mar 20, 2025):
It's just crazy how this was decided per design from the beginning. It goes against all the best practices of any website.
First report was in 2017, 8years later, changing the domain name or IP still breaks the whole database.
@ssddanbrown commented on GitHub (Mar 20, 2025):
@alexisfrjp To confirm, for changes (non-simultaneous use/switching) there's a helper command which will update all relevant URL references in the database: https://www.bookstackapp.com/docs/admin/commands/#update-system-url
@alexisfrjp commented on GitHub (Mar 20, 2025):
Thanks, doesn't solve the public/private accesses but I'm reassured I can still access my data if I change.
@scvnc commented on GitHub (Mar 21, 2025):
Firstly, thank you for maintaining this software. The design decision to bake in APP_URL isn't terribly odd, but does get tricky for managing more than one valid access url. Tor is certainly one use case.
"Have the ability to host a single BookStack instance at multiple base URLs," seems to be the core of it, I agree. In my testing, it seems like the APP_URL is written to the database for media content which is largely one of the issues. At a glance there may be some cookie/security things to address as well.
Perhaps there is nginx lua script that will do a string replace on the body of responses, replacing APP_URL with the accepted Tor host APP_URL equivalent. Either that or somewhere else in the stack. If that seems possible, I'm interested in hacking at it sometime.
@OptimusGREEN commented on GitHub (Dec 15, 2025):
Im suddenly in need of a second url, Is this being worked on?
@ssddanbrown commented on GitHub (Jan 20, 2026):
Just to confirm, this is not something being worked on at all.
A Reddit comment made me realise I've never really expanded upon my thoughts in this main thread, like I have elsewhere at times. So reposting here to provide a little context:
Originally this was a decision made very early to ease implementation with the editor. Using absolute URLs help completely avoid a bunch of more complex scenarios, especially around proxy and sub-path-hosting environments.
Since then, it's actually become quite useful, since it provides a base string to search upon. This allows a range of things like accurately mass updating of the URL (and/or sub-path), or easily identification of internal links for tracking internal references, and for transforming content in exports/imports. It also means the links are technically valid when pulled out to different contexts (exports, API usage etc...).
I appreciate that from a developer point of view that it might seem non-optimal, especially if wanting to host via multiple origin names, but when I weigh up the trade-offs that's quite a minor use-case/benefit relative to the advantages I've come to appreciate from absolute URLs.
@disconsented commented on GitHub (Jan 20, 2026):
Look ma I'm on the tellyAppreciate the response, glad that it's just a simple oversight.
That said, it may be prudent to mark this as not planned and close the issue.