-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Set root
correctly for Gradio apps that are deployed behind reverse proxies
#7411
Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/335daba3999f0c478ae2d62cfa051be8a170476d/gradio-4.18.0-py3-none-any.whl Install Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@335daba3999f0c478ae2d62cfa051be8a170476d#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
root path
correctlyroot
correctly for Gradio apps that are deployed behind reverse proxies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix @abidlabs !
Thanks @freddyaboulton for the review! I'll clean this up tomorrow and merge it in. cc @pngwn and @aliabid94 as well if y'all wanna take a look at this before that |
This PR fixes the issues that we're seeing around the
root
url when Gradio apps are deployed behind nginx or other reverse proxies. As far as I can tell, there were two separate issues:root_path
parameter inBlocks
was being ignored. This parameter is needed to tell Gradio (FastAPI really) the subpath where the Gradio app is being served from. E.g. if you are serving Gradio onwww.mydomain.com/demo
, it should be/demo
. Now, its correctly accounted for. While its hard to write an end-to-end test for this, I have added unit tests forget_root_url()
and I have tested it by running an nginx reverse proxy on an ec2 instance here: http://35.85.61.147/gradio-demo/Main:
This PR:
root
in the config. However, sometimes this header is not set correctly, or it fails to contain the protocol information. This causes a problem on websites that are using https because we try to fetch certain gradio static assets on http, which browsers automatically block. I added another check in the frontend to check to see if current window is being served with https and if so, upgrade the config.root to be https as wellCloses: #7391 (as confirmed by @pseudotensor)
Closes: #7317
(May close?) #6920