Thanks for created great product.
I’m setting up Nginx proxy front of Streamlit, but unsuccessful.
The error in browser: “WebSocket connection to ‘ws…stream’ failed: Error during WebSocket handshake: Unexpected response code: 403”
This just about works for me except that: if I want the app to be hosted at /myapp, I find that streamlit looks for /myapp/stream and /myapp/healthz, but looks for static items at an absolute /static URL.
This is probably by design but it could easily conflict with /static based on the main site.
The sample nginx configuration given above implies that you are seeing something different - stream accessed at /stream instead of /streamlit-components-demo/stream (although my nginx knowledge is limited), so maybe I’m missing some other configuration you’ve already set.
Is there a configuration option in streamlit asking for static assets to be fetched from a relative URL, i.e. /myapp/static in my case?
@tokestermw Hi could you share some tips that made it work for you? My app is also encountering serious slow downs with Nginx using the same configs discussed here. WebSocket is closed before the connection is established
When I access the server directly using IP:8501, the app loads instantly but accessing through domain name and Nginx just keeps the app on Connecting... Please wait
@Anh_Chu Having the same problems as you do. Any ideas?
I’m using a reverse proxy with Nginx based on @virusvn recommendation on configuration: if I visit using IP:<streamlit-port> everything works just fine, if I visit going through Nginx IP/app (where I redirect to IP:<streamlit-port> with Nginx, it succesfully redirects, but streamlit remains stuck in Connecting... Please Wait. Nginx logs shows 403 forbidden errors on /healthz.
I’m using streamlit 0.56, and using Docker with docker-compose and 2 services: one container to deploy the app, and one container for nginx. They are both part of the network created by default, so callable by their service name.
Update:
The nginx configuration here helped me: Host streamlit app at a subfolder . The problem was that I was redirecting IP/app to IP:<streamlit-port> but I was doing so for the stream endpoint without prefixing with app. I set the location block to /app/stream/ (like in the list of the answer), and it worked.
Glad you resolved it. I think my problem is simply a DNS resolver problem on the WebSocket because end users of my app actually report spotless performance haha. Using the same settings as you do.
Thank you very much. Could you please also provide equivalent config for Apache? I’d really appreciate it as I know very little about networking. Thanks!
When I do that, I cannot start streamlit:
Traceback (most recent call last):
File “/home/ubuntu/miniconda3/envs/ms-mint/bin/streamlit”, line 5, in
from streamlit.cli import main
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/init.py”, line 76, in
from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/delta_generator.py”, line 18, in
from streamlit import caching
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/caching.py”, line 40, in
from streamlit.hashing import Context
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/hashing.py”, line 39, in
from streamlit.folder_black_list import FolderBlackList
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/folder_black_list.py”, line 39, in
if config.get_option(“global.developmentMode”):
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/config.py”, line 86, in get_option
parse_config_file()
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/config.py”, line 991, in parse_config_file
_update_config_with_toml(file_contents, filename)
File “/home/ubuntu/miniconda3/envs/ms-mint/lib/python3.9/site-packages/streamlit/config.py”, line 910, in _update_config_with_toml
for name, value in options.items():
AttributeError: ‘bool’ object has no attribute ‘items’
@Soren , your issue is likely in the streamlit config file in ~/.streamlit/config.toml. It is possible it is not formatted as a toml file, thus the parser fails to read it resulting in your error. See this for how to format the config properly: Streamlit configuration — Streamlit 0.75.0 documentation
@ngbala6 welcome to the Community, I read your post through the link you shared and I must say it was superb and I recommend anyone having a challenge setting up Nginx
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.