From 7d217fcc7d7d62351be008fe1b4c0b3a060a435f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Feb 2026 11:41:31 +0000 Subject: [PATCH 1/2] Bind Streamlit to all interfaces (0.0.0.0) in all Docker modes In single-instance mode, `streamlit run app.py` was invoked without `--server.address`, causing Streamlit to default to localhost and be unreachable from outside the container. This adds `--server.address 0.0.0.0` to the single-instance entrypoint in both Dockerfiles, sets `address = "0.0.0.0"` in .streamlit/config.toml, and makes the nginx listen directive in Dockerfile_simple explicitly bind 0.0.0.0. https://claude.ai/code/session_01GX2U6UAAj8sF1smN9Lc4J5 --- .streamlit/config.toml | 1 + Dockerfile | 2 +- Dockerfile_simple | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.streamlit/config.toml b/.streamlit/config.toml index 983fc96a..f38f6b91 100644 --- a/.streamlit/config.toml +++ b/.streamlit/config.toml @@ -5,6 +5,7 @@ gatherUsageStats = false developmentMode = false [server] +address = "0.0.0.0" maxUploadSize = 200 #MB port = 8501 # should be same as configured in deployment repo diff --git a/Dockerfile b/Dockerfile index fca5d17b..a16bf9aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -215,7 +215,7 @@ if [ "$SERVER_COUNT" -gt 1 ]; then\n\ else\n\ # Single instance mode (default) - run Streamlit directly on port 8501\n\ echo "Starting Streamlit app..."\n\ - exec streamlit run app.py\n\ + exec streamlit run app.py --server.address 0.0.0.0\n\ fi\n\ ' > /app/entrypoint.sh # make the script executable diff --git a/Dockerfile_simple b/Dockerfile_simple index 8b066a7c..0cb5f2b3 100644 --- a/Dockerfile_simple +++ b/Dockerfile_simple @@ -112,7 +112,7 @@ if [ "$SERVER_COUNT" -gt 1 ]; then\n\ \n\ # Write nginx config\n\ mkdir -p /etc/nginx\n\ - echo -e "worker_processes auto;\\npid /run/nginx.pid;\\n\\nevents {\\n worker_connections 1024;\\n}\\n\\nhttp {\\n client_max_body_size 0;\\n\\n map \\$cookie_stroute \\$route_key {\\n \\x22\\x22 \\$request_id;\\n default \\$cookie_stroute;\\n }\\n\\n upstream streamlit_backend {\\n hash \\$route_key consistent;\\n${UPSTREAM_SERVERS} }\\n\\n map \\$http_upgrade \\$connection_upgrade {\\n default upgrade;\\n \\x27\\x27 close;\\n }\\n\\n server {\\n listen 8501;\\n\\n location / {\\n proxy_pass http://streamlit_backend;\\n proxy_http_version 1.1;\\n proxy_set_header Upgrade \\$http_upgrade;\\n proxy_set_header Connection \\$connection_upgrade;\\n proxy_set_header Host \\$host;\\n proxy_set_header X-Real-IP \\$remote_addr;\\n proxy_set_header X-Forwarded-For \\$proxy_add_x_forwarded_for;\\n proxy_set_header X-Forwarded-Proto \\$scheme;\\n proxy_read_timeout 86400;\\n proxy_send_timeout 86400;\\n proxy_buffering off;\\n add_header Set-Cookie \\x22stroute=\\$route_key; Path=/; HttpOnly; SameSite=Lax\\x22 always;\\n }\\n }\\n}" > /etc/nginx/nginx.conf\n\ + echo -e "worker_processes auto;\\npid /run/nginx.pid;\\n\\nevents {\\n worker_connections 1024;\\n}\\n\\nhttp {\\n client_max_body_size 0;\\n\\n map \\$cookie_stroute \\$route_key {\\n \\x22\\x22 \\$request_id;\\n default \\$cookie_stroute;\\n }\\n\\n upstream streamlit_backend {\\n hash \\$route_key consistent;\\n${UPSTREAM_SERVERS} }\\n\\n map \\$http_upgrade \\$connection_upgrade {\\n default upgrade;\\n \\x27\\x27 close;\\n }\\n\\n server {\\n listen 0.0.0.0:8501;\\n\\n location / {\\n proxy_pass http://streamlit_backend;\\n proxy_http_version 1.1;\\n proxy_set_header Upgrade \\$http_upgrade;\\n proxy_set_header Connection \\$connection_upgrade;\\n proxy_set_header Host \\$host;\\n proxy_set_header X-Real-IP \\$remote_addr;\\n proxy_set_header X-Forwarded-For \\$proxy_add_x_forwarded_for;\\n proxy_set_header X-Forwarded-Proto \\$scheme;\\n proxy_read_timeout 86400;\\n proxy_send_timeout 86400;\\n proxy_buffering off;\\n add_header Set-Cookie \\x22stroute=\\$route_key; Path=/; HttpOnly; SameSite=Lax\\x22 always;\\n }\\n }\\n}" > /etc/nginx/nginx.conf\n\ \n\ # Start Streamlit instances on internal ports (localhost only)\n\ for i in $(seq 0 $((SERVER_COUNT - 1))); do\n\ @@ -127,7 +127,7 @@ if [ "$SERVER_COUNT" -gt 1 ]; then\n\ else\n\ # Single instance mode (default) - run Streamlit directly on port 8501\n\ echo "Starting Streamlit app..."\n\ - exec streamlit run app.py\n\ + exec streamlit run app.py --server.address 0.0.0.0\n\ fi\n\ ' > /app/entrypoint.sh # make the script executable From 0203a867626575b9d7bbd51be65301a75b413fe9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 10 Feb 2026 11:53:47 +0000 Subject: [PATCH 2/2] Bind multi-instance Streamlit to all interfaces (0.0.0.0) The load-balanced Streamlit instances were still using --server.address 127.0.0.1, causing them to only listen on localhost. Change to 0.0.0.0 so Streamlit listens on all IPs in all cases (single-instance and multi-instance). https://claude.ai/code/session_01GX2U6UAAj8sF1smN9Lc4J5 --- Dockerfile | 4 ++-- Dockerfile_simple | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index a16bf9aa..9481ce8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -202,11 +202,11 @@ if [ "$SERVER_COUNT" -gt 1 ]; then\n\ mkdir -p /etc/nginx\n\ echo -e "worker_processes auto;\\npid /run/nginx.pid;\\n\\nevents {\\n worker_connections 1024;\\n}\\n\\nhttp {\\n client_max_body_size 0;\\n\\n map \\$cookie_stroute \\$route_key {\\n \\x22\\x22 \\$request_id;\\n default \\$cookie_stroute;\\n }\\n\\n upstream streamlit_backend {\\n hash \\$route_key consistent;\\n${UPSTREAM_SERVERS} }\\n\\n map \\$http_upgrade \\$connection_upgrade {\\n default upgrade;\\n \\x27\\x27 close;\\n }\\n\\n server {\\n listen 0.0.0.0:8501;\\n\\n location / {\\n proxy_pass http://streamlit_backend;\\n proxy_http_version 1.1;\\n proxy_set_header Upgrade \\$http_upgrade;\\n proxy_set_header Connection \\$connection_upgrade;\\n proxy_set_header Host \\$host;\\n proxy_set_header X-Real-IP \\$remote_addr;\\n proxy_set_header X-Forwarded-For \\$proxy_add_x_forwarded_for;\\n proxy_set_header X-Forwarded-Proto \\$scheme;\\n proxy_read_timeout 86400;\\n proxy_send_timeout 86400;\\n proxy_buffering off;\\n add_header Set-Cookie \\x22stroute=\\$route_key; Path=/; HttpOnly; SameSite=Lax\\x22 always;\\n }\\n }\\n}" > /etc/nginx/nginx.conf\n\ \n\ - # Start Streamlit instances on internal ports (localhost only)\n\ + # Start Streamlit instances on internal ports\n\ for i in $(seq 0 $((SERVER_COUNT - 1))); do\n\ PORT=$((BASE_PORT + i))\n\ echo "Starting Streamlit instance on port $PORT..."\n\ - streamlit run app.py --server.port $PORT --server.address 127.0.0.1 &\n\ + streamlit run app.py --server.port $PORT --server.address 0.0.0.0 &\n\ done\n\ \n\ sleep 2\n\ diff --git a/Dockerfile_simple b/Dockerfile_simple index 0cb5f2b3..a2cfd907 100644 --- a/Dockerfile_simple +++ b/Dockerfile_simple @@ -114,11 +114,11 @@ if [ "$SERVER_COUNT" -gt 1 ]; then\n\ mkdir -p /etc/nginx\n\ echo -e "worker_processes auto;\\npid /run/nginx.pid;\\n\\nevents {\\n worker_connections 1024;\\n}\\n\\nhttp {\\n client_max_body_size 0;\\n\\n map \\$cookie_stroute \\$route_key {\\n \\x22\\x22 \\$request_id;\\n default \\$cookie_stroute;\\n }\\n\\n upstream streamlit_backend {\\n hash \\$route_key consistent;\\n${UPSTREAM_SERVERS} }\\n\\n map \\$http_upgrade \\$connection_upgrade {\\n default upgrade;\\n \\x27\\x27 close;\\n }\\n\\n server {\\n listen 0.0.0.0:8501;\\n\\n location / {\\n proxy_pass http://streamlit_backend;\\n proxy_http_version 1.1;\\n proxy_set_header Upgrade \\$http_upgrade;\\n proxy_set_header Connection \\$connection_upgrade;\\n proxy_set_header Host \\$host;\\n proxy_set_header X-Real-IP \\$remote_addr;\\n proxy_set_header X-Forwarded-For \\$proxy_add_x_forwarded_for;\\n proxy_set_header X-Forwarded-Proto \\$scheme;\\n proxy_read_timeout 86400;\\n proxy_send_timeout 86400;\\n proxy_buffering off;\\n add_header Set-Cookie \\x22stroute=\\$route_key; Path=/; HttpOnly; SameSite=Lax\\x22 always;\\n }\\n }\\n}" > /etc/nginx/nginx.conf\n\ \n\ - # Start Streamlit instances on internal ports (localhost only)\n\ + # Start Streamlit instances on internal ports\n\ for i in $(seq 0 $((SERVER_COUNT - 1))); do\n\ PORT=$((BASE_PORT + i))\n\ echo "Starting Streamlit instance on port $PORT..."\n\ - streamlit run app.py --server.port $PORT --server.address 127.0.0.1 &\n\ + streamlit run app.py --server.port $PORT --server.address 0.0.0.0 &\n\ done\n\ \n\ sleep 2\n\