bitfocus / companion

Bitfocus Companion enables the reasonably priced Elgato Stream Deck and other controllers to be a professional shotbox surface for an increasing amount of different presentation switchers, video playback software and broadcast equipment.
http://bitfocus.io/companion
Other
1.57k stars 500 forks source link

Nginx proxy base url #2255

Open miuratv opened 1 year ago

miuratv commented 1 year ago

Is this a feature relevant to companion itself, and not a module?

Is there an existing issue for this?

Describe the feature

I'm trying to put a companion running via docker under a nginx reverse proxy: the setup would work fine, but every link is broken because it refers to "/" url and not "/companion/".

I tried some nginx rewrite url to no avail, and i think it would be a nice security feature in general to avoid random access to obvious 8000 port.

Usecases

if a nginx reverse proxy tries to open the url "http://ipaddress/companion/" instead of the usual "http://ipaddress:8000" the page loads blank as every resource still points to "http://ipaddress/".

Manually editing the url points to the resource.

Julusian commented 1 year ago

It looks like it is possible to configure vite to support this https://github.com/vitejs/vite/pull/8450, any custom urls we expose will probably need manually changing to use the same prefix function.

The challenge here will be figuring out where this path/prefix should be defined, and how to propogate that into the ui when the page loads

Julusian commented 1 month ago

Maybe part of the solution here is to make the express server do some search and replace within the html file when serving it. It could either adjust the paths to be relative to the root, or listen to a header to know what the hosted path is.

The ui would need to know the prefix to know what to add when generating urls, and what to strip in the router, perhaps that same header value can be forwarded to the ui for this