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

(feat) allow deployment under relative base path #1701

Closed
wants to merge 3 commits into from

Conversation

behackl
Copy link

@behackl behackl commented Apr 23, 2024

Pull Request Checklist

  • Description: Briefly describe the changes in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: Have you updated relevant documentation?
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?

Description

This introduces some changes mainly to the frontend (plus the construction of manifest.json in the backend) that allows setting a relative base path via the environment variable (or, in the context of the docker build process, the build argument) WEBUI_BASE_PATH.

Please note: I am not familiar with svelte at all, and it feels like there might be a much simpler solution than what I did here -- however, I've used this branch to deploy a working instance behind a standard reverse proxy configuration (in this case Apache):

ProxyPreserveHost On
ProxyPass /chat http://example.com:8077
ProxyPassReverse /chat http://example.com:8077

such that the interface is available at https://original.example.com/chat.

Related to #1162.

Unfortunately I won't have time to put much more effort towards this, maybe this can be useful to whoever comes up with a proper implementation of this feature eventually. :-)


Changelog Entry

Added

  • Docker build argument WEBUI_BASE_PATH which controls the relative base path used in the built frontend (plus in manifest.json).

@krosk
Copy link

krosk commented Apr 23, 2024

Nice work !

I had a try, it seems in the current implementation, WEBUI_BASE_PATH can be changed at docker build time only, not at deployment time. Is it correct?

@behackl
Copy link
Author

behackl commented Apr 23, 2024

Thanks!

WEBUI_BASE_PATH can be changed at docker build time only, not at deployment time. Is it correct?

Indeed, this solution only works when building the docker image.

A version that works during deployment time too would require restructuring the docker build process a bit; currently node is only available in the first build stage (and not in the final container). The frontend would need to be rebuilt whenever the container starts up.

@tjbck tjbck changed the base branch from main to dev April 26, 2024 17:05
@tjbck
Copy link
Contributor

tjbck commented May 6, 2024

Closing due to conflicts. Unless there's a more elegant solution to this, we should just add docs on how to host our webui with a relative base path using other reverse proxy tools like nginx. I'm not a huge fan of this current solution for adding relative base path support natively. I appreciate the effort you put in regardless 🙌

@tjbck tjbck closed this May 6, 2024
@behackl behackl deleted the feat-relative-base-path branch May 6, 2024 23:06
@behackl
Copy link
Author

behackl commented May 6, 2024

I guess it would still be necessary to change the frontend-generated URLs from absolute to relative ones. Except if you were thinking of some sort of automatic URL rewriting by the reverse proxy; I've found these sort of solutions to be somewhat unreliable though.

In any case, I'm sure someone will be able to come up with a clean solution. :-)

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

Successfully merging this pull request may close these issues.

None yet

3 participants