Hi, I want to run streamlit inside a docker container that is hosted on an AWS EC2 instance.
The company configured the AWS instance to only be accessible from a certain IP range thus providing the URL would not help with this use case.
Locally every thing runs fine, by both using direct access using port 8501 but also by using nginx.
On AWS however it does not.
Remark: When I access the instance via ssh and configure a port forwarding, everything works as fine.
When I want to accress the website regularly by using IP:Port, I get a website that only shows the skeleton:
The health check (ip:port/_stcore/health) also returns status code 200.
I also read this URL remote-start and used “python -m streamlit run --server.address 0.0.0.0 --server.port=8501 --server.enableCORS=false --server.enableWebsocketCompression=false --server.enableXsrfProtection=false index.py”. That didn’t change anything either.
There seem to be websocket related issues:
I really hope the streamlit team will do more testing with nginx reverse proxies and come up with a troubleshooting guide. I have the same problem, but only from browsers other than Safari for some reason. I used to have this problem on ANY browser when accessing the application from outside of the intranet where it’s deployed (and still it worked exclusively with the intranet-facing IPaddress:8501).
What I can advise is that you add this to the configuration to NginX:
Thanks for your reply. I found this exact approach in another post but unfortunatley it did not resolve my issue. My issue is also not related to nginx as it is exactly the same whether if I try to access the app via nginx or directly via exposed port
In this case you can try taking the trailing slash out of the location descriptor.
location /_stcore/stream { # notice no slash trailing here
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
proxy_pass http://YOUR-APP-IP:8501/_stcore/stream; # notice no slash trailing here either
}
You may want to do this with the parent location too if it’s not root, or as an alternative, go for the descriptor as location = /_stcore/stream/ , which should work as well. Refer to this article as to the rationale for this.
Note that this took some time for me to figure out, and that it’s quite unbelievable that nobody from the dev team seems to know this. I swear to you this is 90% of the problems people are getting with streamline behind a reverse proxy, and in tens of posts on this matter I have seen nobody mentioning this.
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.