Cannot use nginx proxy

Hello everyone

I use nginx to proxy gradio app, for example, https://ip:port/chat/ agent http://127.0.0.1/ Can’t find theme.css, can’t join websocket. How do I set it up

1 Like

please look at this live example, using Nginx with Gradio

hello , your sample can proxy gradio in a root path ‘/’, but it is failed to proxy in a path like ‘/blabla’, the page is blank. do you have any idea to make this OK ?

do you have any route serving on / the Space manager needs something on / in order to successfully load

do you mean the websocket ? i saw the websocket connection request is coming to the ‘/’ path, is it some way to fix this ?

can you please share you nginx.conf?

here is my nginx.conf which flow by your example , it is work.


...
server {
                                                listen       8000;
                        server_name somedomain 192.168.1.200;

#location / {
#        root /usr/share/nginx/html;
#        index index.html;
#    }

                location / {

proxy_pass http://192.168.1.253:7860;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_cache_bypass $http_upgrade;
        proxy_read_timeout 86400;
        proxy_redirect off;

                }

        }

here is the folder path version which FAILED:

location /test {

proxy_pass http://192.168.1.253:7860;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_cache_bypass $http_upgrade;
        proxy_read_timeout 86400;
        proxy_redirect off;

                }

        }

it is failed by not show the web ui, instead show up the json result “not found”
图片

Maybe this could help someone to configure reverse proxy for Gradio.