CausalBox / nginx.conf
ShutterStack's picture
Update nginx.conf
cb0e0e4 verified
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# Redirect Nginx logs to Docker's standard output/error streams
error_log /dev/stderr info;
access_log /dev/stdout combined;
# Set writable paths for Nginx temporary files to avoid permission errors
# These paths correspond to directories created and permissioned in your Dockerfile
client_body_temp_path /tmp/nginx_cache/client_body;
proxy_temp_path /tmp/nginx_cache/proxy;
# Gzip settings for improved performance (optional but recommended)
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 7860; # Hugging Face Spaces default port for Docker SDK
server_name localhost;
# Serve Streamlit app at the root (/)
location / {
proxy_pass http://localhost:8501; # Streamlit's default port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# Increase timeouts if Streamlit app takes long to load/respond or for large uploads
proxy_read_timeout 300s;
proxy_send_timeout 300s;
# Allow larger file sizes if necessary, Nginx default is 1M. This is for requests proxied through Nginx.
client_max_body_size 50M; # Adjust as needed for larger file uploads via Streamlit's internal mechanism
}
# This section is commented out as it's typically not needed for a Streamlit+Flask setup where
# Streamlit calls Flask directly via localhost:5000.
# If you needed to expose Flask publicly on a subpath, you'd uncomment and configure this.
# location /api/ {
# proxy_pass http://localhost:5000/;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# client_max_body_size 50M; # Adjust for Flask API if it also handles uploads
# }
}
}