silverbullet
silverbullet copied to clipboard
Support hosting at a URL path
I'm wanting to put an instance of silverbullet
behind an Nginx proxy at a particular path. For example:
location ~ /silverbullet(.*) {
proxy_pass http://127.0.0.1:3000$1;
}
However, this does not work beyond the main index page since it attempts to download assets without prepending the /silverbullet
path to the requests.
Is there a way to configure silverbullet
or Deno to use a URL path (or recompile silverbullet
with a URL path)?
I know I could just host silverbullet
at a subdomain but for this particular situation using a subdomain is not an option.
Not possible right now, but should not be very hard to add.
Okay @zefhemel thanks for the reply. I'll see if I can't poke around and make something work then submit a PR.
That's be perfect. A few pointers, this is the main entrypoint for navigating in the editor (e.g. when clicking links): https://github.com/silverbulletmd/silverbullet/blob/main/web/editor.tsx#L638 which defers most of the logic to this: https://github.com/silverbulletmd/silverbullet/blob/main/web/navigator.ts
The Editor
constructor already has a urlPrefix
argument: https://github.com/silverbulletmd/silverbullet/blob/main/web/editor.tsx#L146 which is hardcoded to "" for now: https://github.com/silverbulletmd/silverbullet/blob/main/web/boot.ts#L11
So looking at this, this may actually not be so hard. Give it a shot! Question to figure out is still how you'd want to configure this. Perhaps a command line argument? And then how you pass that configuration on to the web UI, perhaps by somehow injecting it into index.html (which is fully static right now).
I forgot about the server side of course. All routes are defined in http_server.ts so that should be easy to find.
Following, I was having troubles getting this to work as well and thought it was just nginx, but it's probably this.
Wanted to check in on this -- silverbullet
looks really cool and I'd be interested in putting it behind Nginx as well.
The way I work around this myself is to simply put things on a separate (sub) domain. You probably considered this already, but just saying.
While i indeed too use silverbullet on a subdomain, i think having the option to host on a sub-path is a really needed feature. Not everyone want/can spin subdomains. For example, i would want to host silverbullet at work but obtaining subdomains trough corporate is impossibile so i would need to host on the one we already have, not cannot do that on root as well (no write access to root).