So hosting with nginx is tricky, but I’ve gotten most of it to work with multiple proxy passes as suggested here: How to use Streamlit with Nginx?
However, media like images is still an issue and I can’t figure out how to configure the proxy pass for those. Here’s the full nginx config I got currently:
I’ve tried removing the trailing slash on media but that doesn’t work either. Anyone got any ideas?
edit: forgot to write i’ve tried with and without https on the proxy pass for media, as the link when inspecting the html element looked like it was using https
It would be good to have a look at the networking tab on the media file. I would be curious to see if there is any problem in the way we generate the urls.
From what I can see in the network dev tools tab, I get a 403 forbidden for the media files, using the nginx config I posted above (just with ‘banditapp’ instead of ‘app’). The fonts work fine, so it’s a bit curious media files don’t.
By the way, do you know why it’s the case we need so many proxy_pass commands? Whenever I’ve used other apps, for example ghost blog, it’s always sufficient with one proxy_pass.
If you are still facing the issue, I was facing the same issue for media and solved it by adding - location ^~ /media {
proxy_pass http://127.0.0.1:8501/media;
}
Still doesn’t work for me Have tried /media/media/media/ for the location and with and without trailing slash at end of the proxypass URL. All of these with and without https.
Unfortunately the streamlit --log_level debug outputs absolutely nothing so it’s difficult to know what’s going on. Streamlit is copying and/or renaming the file and then serving it so it would have been very useful to have streamlit logs output something in terminal.
One of the image files is in same directory as streamlit python file with the same permissions. The other image file is automatically created by matplotlib so that should work even if permissions on the former mentioned file were wrong.
I’m probably missing something obvious
What does the rest of your nginx config look like @Nishtha_Goswami?
Hi @fohria. So I have two streamlit apps running on 8501 and 8502(/help). Only web app running at 8502 has some media and thus require the /media path. I have attached my Nginx configuration for the same below.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.