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: relative path support #1162

Closed
hahchenchen opened this issue Mar 14, 2024 · 13 comments
Closed

feat: relative path support #1162

hahchenchen opened this issue Mar 14, 2024 · 13 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed non-core maintainers aren't looking into this/low priority

Comments

@hahchenchen
Copy link

Bug Report

webui docker images do not support relative path.

Description

for xample, i want to start webui at localhost:8080/webui/, does the image parameter support the relative path configuration?

@hahchenchen
Copy link
Author

@tjbck

@blackshot
Copy link

blackshot commented Mar 14, 2024

i'm facing the same issue, i can't deploy it behind a reverse proxy under specific path only because static files doesn't have the path prefix
image

@CyberIngeniero
Copy link

I also have the same problem.

@tjbck tjbck changed the title Relative path webui is not supported feat: relative path support Mar 14, 2024
@tjbck tjbck added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Mar 14, 2024
@tjbck
Copy link
Contributor

tjbck commented Mar 14, 2024

If not officially supported, but I can see that being useful for a lot of people. Feel free to make a PR!

@justinh-rahb
Copy link
Collaborator

This can be accomplished through reverse-proxy and request rewrite rules as well.

@blackshot
Copy link

blackshot commented Mar 14, 2024

This can be accomplished through reverse-proxy and request rewrite rules as well.

nope, i deployed it behind a reverse proxy but static files needs to be compiled with basepath too

@blackshot
Copy link

@hahchenchen
Copy link
Author

This can be accomplished through reverse-proxy and request rewrite rules as well.

no, the proxy is not useful. the static files path is hard code.

@tjbck tjbck added the non-core maintainers aren't looking into this/low priority label Mar 15, 2024
@hass-demacia
Copy link

hass-demacia commented Mar 25, 2024

Use caddy2, Caddyfile config

        rewrite /_app/* /open-webui{http.request.uri}

        handle_path /open-webui/* {
                reverse_proxy http://localhost:8080
        }

It seems browser can fetch javascript static files, but get a runtime error:

app.78c246b0.js:1 Error: Not found: /open-webui/
    at ce (start.867272e0.js:1:14918)
    at re (start.867272e0.js:1:8155)
    at Object.goto (start.867272e0.js:1:18073)
    at Module.Nt (start.867272e0.js:3:1691)
    at open-webui/:66:11

@behackl
Copy link

behackl commented Apr 23, 2024

I've successfully deployed an instance behind a reverse proxy from a subdirectory using the branch attached to #1701. I wouldn't say that I am particularly happy with the way how I solved it, but perhaps this is useful to whoever decides to work on a proper implementation. 😄

@tjbck tjbck closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
@lmorin-inria
Copy link

The feature was critical for me. I have implemented it there:
https://github.com/lmorin-inria/open-webui/tree/feat/base-path-relocatable

The path is set dynamically when launching the container (variable). I will had a documentation if there are people asking for it.

The MR was rejected. I will keep that fork up to date from time to time with only that feature for the next few weeks at least.

@TomlDev
Copy link

TomlDev commented May 28, 2024

I am interested @lmorin-inria!
I tried with our nginx proxy and this config where I rewrite the URL and use sub_filters to rewrite all paths:

        location /ai/ {
            rewrite ^/ai(/.*)$ /$1 break;
            proxy_pass http://10.0.0.3:8080;
            proxy_http_version 1.1;

            sub_filter_types application/javascript application/json text/css text/html;
            sub_filter_once off;
            sub_filter 'href="/' 'href="/ai/';
            sub_filter 'src="/' 'src="/ai/';
            sub_filter 'action="/' 'action="/ai/';
            sub_filter 'import("/' 'import("/ai/';

            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
            proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

It is able to rewrite most of the calls, but not all as it seems:
grafik

@lmorin-inria
Copy link

lmorin-inria commented May 28, 2024

You are welcome.

The container I propose does not need any rewriting. That's the point, Sveltes uses a single page design template, and does not support URL rewriting. I fix this by configuring at runtime the "path" location.

However I can see that in your configuration you try to rewrite the path. You should not probably.

=> When you launch the container, set the "ROOT_PATH" :
docker (...) -e ROOT_PATH= (...)

In you case your might use that syntax :
docker (...) -e ROOT_PATH=ai (...)

And the web server will serve the frontend pages in
http://10.0.0.3:8080/ai/app

The backend answer to
http://10.0.0.3:8080/ai/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed non-core maintainers aren't looking into this/low priority
Projects
None yet
Development

No branches or pull requests

9 participants