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.