I am currently hosting a Streamlit application behind an Nginx reverse proxy and I am encountering some issues with the routing of requests.
Overview of the Setup
-
Streamlit Application : The application runs on
http://localhost:8501
-
Nginx Configuration : I have set up Nginx to serve the application and handle requests. Below is a simplified version of my current Nginx configuration
server {
listen 80;
server_name [url_name];
access_log “C:\forecast\access.log” main;
error_log “C:\forecast\error.log” error;location / {
proxy_pass http://localhost:8501/;
}location ^~ /_stcore/static {
proxy_pass http://localhost:8501/static;
}location ^~ /_stcore/healthz {
proxy_pass http://localhost:8501/_stcore/healthz;
}location ^~ /_stcore/vendor {
proxy_pass http://localhost:8501/_stcore/vendor;
}location /_stcore/stream {
proxy_pass http://localhost:8501/_stcore/stream;
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_set_header Sec-WebSocket-Extensions $http_sec_websocket_extentions;
proxy_read_timeout 85400;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}error_page 500 502 503 504 /50x.html;
location = /50x.html {
root C:\nginx-1.23.4\html;
}
}
Issues Encountered
When I attempt to access non-existent paths (e.g., [url]/dashboard or [url]/sdfsdgfrfg), there are continuous network requests to files like stream, health, and host-config, returning status code 304.
I would greatly appreciate any guidance you could provide on configuring Nginx correctly to ensure that all requests (even non-existing pages) are appropriately routed to the Streamlit application URL.