silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

Support hosting at a URL path

Open activeshadow opened this issue 2 years ago • 11 comments

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.

activeshadow avatar Dec 05 '22 17:12 activeshadow

Not possible right now, but should not be very hard to add.

zefhemel avatar Dec 05 '22 17:12 zefhemel

Okay @zefhemel thanks for the reply. I'll see if I can't poke around and make something work then submit a PR.

activeshadow avatar Dec 05 '22 17:12 activeshadow

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

zefhemel avatar Dec 05 '22 19:12 zefhemel

I forgot about the server side of course. All routes are defined in http_server.ts so that should be easy to find.

zefhemel avatar Dec 06 '22 11:12 zefhemel

Following, I was having troubles getting this to work as well and thought it was just nginx, but it's probably this.

ryanwwest avatar Dec 28 '22 05:12 ryanwwest

Wanted to check in on this -- silverbullet looks really cool and I'd be interested in putting it behind Nginx as well.

billbrod avatar Jul 25 '23 01:07 billbrod

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.

zefhemel avatar Jul 25 '23 11:07 zefhemel

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

gardiol avatar Apr 21 '24 08:04 gardiol