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

[Feature Request]: deploy webui on a base_url/subpath instead of / #9546

Open
1 task done
shuaiyy opened this issue Apr 11, 2023 · 23 comments
Open
1 task done

[Feature Request]: deploy webui on a base_url/subpath instead of / #9546

shuaiyy opened this issue Apr 11, 2023 · 23 comments
Labels
bug-report Report of a bug, yet to be confirmed
Milestone

Comments

@shuaiyy
Copy link

shuaiyy commented Apr 11, 2023

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What would your feature do ?

I want to deloy webui on an exist host with subpath, like http://xxx.com/webui/

I tried nginx to for service route,not work.

Proposed workflow

  1. start webui with args --base-url /webui
  2. got the service on http://host:port/webui/

Additional information

No response

@shuaiyy shuaiyy added the enhancement New feature or request label Apr 11, 2023
@simonbermudez
Copy link

This used to work when I first installed SD but now with the new version it doesn't work, not sure what version changed the support

@marsplant
Copy link

I met the same problem, have you solved this?

@AaronWebster
Copy link

What would one need to do to make this change?

@simonbermudez
Copy link

Hey @shuaiyy @marsplant @AaronWebster I found a way of doing it.

I found this PR that includes the change #9865

so In order to implement those changes you only have to switch to the dev branch and then add this to your webui-user.sh

export COMMANDLINE_ARGS="--subpath=/yoursubpath"

@akx
Copy link
Collaborator

akx commented May 28, 2023

Yep, --subpath is now also available on the current master (v1.3.0).

@akx akx closed this as completed May 28, 2023
@Dewey-Ding
Copy link

it not work on the current master .

@Dewey-Ding
Copy link

commit 20ae71f (HEAD -> master, origin/master, origin/HEAD)
Author: AUTOMATIC 16777216c@gmail.com
Date: Sat May 27 20:23:16 2023 +0300

fix linter issue for 1.3.0

@akx
Copy link
Collaborator

akx commented May 29, 2023

@Dewey-Ding What does not work? What did you try?

@Dewey-Ding
Copy link

Dewey-Ding commented May 30, 2023

use this cmd " --subpath aip --skip-torch-cuda-test --no-half " on current master

commit 20ae71f (HEAD -> master, origin/master, origin/HEAD)
Author: AUTOMATIC 16777216c@gmail.com
Date: Sat May 27 20:23:16 2023 +0300

http://127.0.0.1:7860/aip it not work.
http://127.0.0.1:7860 its ok

@akx akx reopened this May 30, 2023
@akx akx added this to the 1.3 milestone May 30, 2023
@akx akx added bug-report Report of a bug, yet to be confirmed and removed enhancement New feature or request labels May 30, 2023
@catalpaaa
Copy link
Contributor

use this cmd " --subpath aip --skip-torch-cuda-test --no-half " on current master

commit 20ae71f (HEAD -> master, origin/master, origin/HEAD) Author: AUTOMATIC 16777216c@gmail.com Date: Sat May 27 20:23:16 2023 +0300

http://127.0.0.1:7860/aip it not work. http://127.0.0.1:7860 its ok

the previous --subpath i implemented was just a workaround as gradio didnt have proper support, i have updated it after they added root_path in 3.30. you can checkout #11478

@jianbohuang
Copy link

jianbohuang commented Jul 10, 2023

In recently gradio version , if you need access gradio from nginx proxy and your gradio not configures a base-url path, it will raise a theme.css 404 not find , or an /info 404 not find.
you can follow this guide for the nginx configuration (https://www.gradio.app/guides/running-gradio-on-your-web-server-with-nginx)

--subpath args no work in SD v1.30,

fix:

  1. upgrade gradio to 3.36.1 or down to 3.29.0 (there are some bug)
  2. add an root_path="/gradio-demo" at there:
    app, local_url, share_url = shared.demo.launch(
  3. remove arg --subpath
  4. access with you inverse proxy with path "/gradio-demo"

@keisukenakamurafc
Copy link

I tried this same method, but the browser shows {"detail":"Not Found"}.

@catalpaaa
Copy link
Contributor

I tried this same method, but the browser shows {"detail":"Not Found"}.

a fix was merged, now you can do --subpath your-path with location /your-path/ { proxy_pass http://localhost:your-port/; } in nginx

@keisukenakamurafc
Copy link

keisukenakamurafc commented Aug 8, 2023

When I clone Master and run it with the following conditions, the result is still the same: {"detail": "Not Found"}.
If you know where I am wrong, I would appreciate it if you could let me know.
The reverse proxy seems to be functioning properly.

  • COMMANDLINE_ARGS
    export COMMANDLINE_ARGS="--subpath=/stablediffusion-webui --listen --no-gradio-queue"
  • Run-time commands
    python3 launch.py --subpath=/stablediffusion-webui --listen --no-gradio-queue
  • .conf of nginx
    listen 80;
    location /stablediffusion-webui{
        proxy_pass http://xxxxxxxxxx:7860;
        proxy_redirect off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
}

@catalpaaa
Copy link
Contributor

When I clone Master and run it with the following conditions, the result is still the same: {"detail": "Not Found"}.

If you know where I am wrong, I would appreciate it if you could let me know.

The reverse proxy seems to be functioning properly.

  • COMMANDLINE_ARGS

export COMMANDLINE_ARGS="--subpath=/stablediffusion-webui --listen --no-gradio-queue"

  • Run-time commands

python3 launch.py --subpath=/stablediffusion-webui --listen --no-gradio-queue

  • .conf of nginx

    listen 80;

    location /stablediffusion-webui{

        proxy_pass http://xxxxxxxxxx:7860;

        proxy_redirect off;

        proxy_http_version 1.1;

        proxy_set_header Upgrade $http_upgrade;

        proxy_set_header Connection "upgrade";

        proxy_set_header Host $host;

    }

    access_log /var/log/nginx/access.log;

    error_log /var/log/nginx/error.log;

}

proxy_pass http://xxxxxxxxxx:7860; can you explain this line, if you are running webui on the same machine, you should have a proxy to localhost:7860. If not then please double check if you can access the address directly first.

@keisukenakamurafc
Copy link

It is running on a remote GPU server and "xxxxxxxxxxxx" is marked with an ip address. It has been hidden for security reasons. If no sub-path is attached, it is accessed normally.

@keisukenakamurafc
Copy link

keisukenakamurafc commented Aug 8, 2023

Thank you. I can't seem to do it even with "proxy_pass http://xxxxxxxxxx:7860/stablediffusion-webui/".
It's most likely due to gradio or complex dependencies.

@catalpaaa
Copy link
Contributor

Thank you. I can't seem to do it even with "proxy_pass http://xxxxxxxxxx:7860/stablediffusion-webui/". It's most likely due to gradio or complex dependencies.

I would try and setup the reverse proxy on the GPU server and see if its posible to route back to whatever server you are using.

@liveaverage
Copy link

Adding proxy rewrites in NGINX and launching/starting with the subpath parameter was enough to resolve this. Assuming you want to serve this over subpath /stable:

On your NGINX conf:

location /stable {
    auth_request /oauth2/auth;
    error_page 401 = /oauth2/sign_in;

    proxy_set_header Host $host;

    proxy_pass http://192.168.0.10:7860/;
    rewrite /stable/(.*) /$1 break;
    proxy_redirect off;


    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Scheme $scheme;
    proxy_buffers 4 256k;
    proxy_buffer_size 128k;
    proxy_busy_buffers_size 256k;

}

Startup:

cd /opt/stable-diffusion-webui
./webui.sh --listen --subpath=/stable

@keisukenakamurafc
Copy link

I have resolved this issue! Thank you to everyone!

@David19910809
Copy link

I have resolved this issue! Thank you to everyone!
can you tell me how to resolved

@AlpTuncay
Copy link

Has anyone solved this issue? I am trying to serve this on Kubernetes cluster behind a Virtual Service under a subpath. When I change the root_path of the Gradio application with --subpath option I get the error below

image

My Gradio version is 3.41.2

If solved, can anyone point me in the right direction?

@chillFFF
Copy link

chillFFF commented Dec 11, 2024

By upgrading fastapi to version 0.110.3, I resolved this issue.(gradio==4.40.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report Report of a bug, yet to be confirmed
Projects
None yet
Development

No branches or pull requests