Spaces:
Sleeping
Sleeping
Update nginx.conf
Browse files- nginx.conf +18 -16
nginx.conf
CHANGED
|
@@ -9,12 +9,16 @@ http {
|
|
| 9 |
sendfile on;
|
| 10 |
keepalive_timeout 65;
|
| 11 |
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
gzip on;
|
| 14 |
gzip_vary on;
|
| 15 |
gzip_proxied any;
|
| 16 |
gzip_comp_level 6;
|
| 17 |
-
gzip_types text/plain text/css application/json application/javascript text/xml application/xml
|
| 18 |
|
| 19 |
server {
|
| 20 |
listen 7860; # Hugging Face Spaces default port for Docker SDK
|
|
@@ -28,28 +32,26 @@ http {
|
|
| 28 |
proxy_set_header Connection "upgrade";
|
| 29 |
proxy_set_header Host $host;
|
| 30 |
proxy_cache_bypass $http_upgrade;
|
| 31 |
-
|
|
|
|
| 32 |
proxy_send_timeout 300s;
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
#
|
| 37 |
-
#
|
| 38 |
-
#
|
| 39 |
-
#
|
| 40 |
-
#
|
| 41 |
-
#
|
| 42 |
-
# The Nginx config below is for direct external access to Flask, which is usually not needed when Streamlit is the frontend.
|
| 43 |
-
# I'll keep it simple for now, focusing on Streamlit at root.
|
| 44 |
-
|
| 45 |
-
# If you wanted to expose Flask on a subpath of the Space URL (e.g., yourspace.hf.space/flask_api)
|
| 46 |
-
# you would add a location block like this, but your Streamlit app would still call localhost:5000 internally.
|
| 47 |
-
# location /flask_api/ {
|
| 48 |
# proxy_pass http://localhost:5000/;
|
| 49 |
# proxy_set_header Host $host;
|
| 50 |
# proxy_set_header X-Real-IP $remote_addr;
|
| 51 |
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 52 |
# proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
| 53 |
# }
|
| 54 |
}
|
| 55 |
}
|
|
|
|
| 9 |
sendfile on;
|
| 10 |
keepalive_timeout 65;
|
| 11 |
|
| 12 |
+
# Set a writable path for Nginx temporary files to avoid permission errors
|
| 13 |
+
# This path must correspond to a directory created and permissioned in your Dockerfile (e.g., /tmp/nginx_cache/client_body)
|
| 14 |
+
client_body_temp_path /tmp/nginx_cache/client_body;
|
| 15 |
+
|
| 16 |
+
# Gzip settings for improved performance (optional but recommended)
|
| 17 |
gzip on;
|
| 18 |
gzip_vary on;
|
| 19 |
gzip_proxied any;
|
| 20 |
gzip_comp_level 6;
|
| 21 |
+
gzip_types text/plain text/css application/json application/javascript text/xml application/xml+rss text/javascript;
|
| 22 |
|
| 23 |
server {
|
| 24 |
listen 7860; # Hugging Face Spaces default port for Docker SDK
|
|
|
|
| 32 |
proxy_set_header Connection "upgrade";
|
| 33 |
proxy_set_header Host $host;
|
| 34 |
proxy_cache_bypass $http_upgrade;
|
| 35 |
+
# Increase timeouts if Streamlit app takes long to load/respond or for large uploads
|
| 36 |
+
proxy_read_timeout 300s;
|
| 37 |
proxy_send_timeout 300s;
|
| 38 |
+
# Allow larger file sizes if necessary, Nginx default is 1M. This is for requests proxied through Nginx.
|
| 39 |
+
client_max_body_size 50M; # Adjust as needed for larger file uploads via Streamlit's internal mechanism
|
| 40 |
}
|
| 41 |
|
| 42 |
+
# If you were to expose Flask directly under a subpath (e.g., /api/),
|
| 43 |
+
# this is where you would configure it.
|
| 44 |
+
# However, for internal communication from Streamlit to Flask,
|
| 45 |
+
# Streamlit should directly call http://localhost:5000/preprocess/upload etc.
|
| 46 |
+
# This block is often not needed if Streamlit is the sole public-facing app.
|
| 47 |
+
# Example if you needed it:
|
| 48 |
+
# location /api/ {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
# proxy_pass http://localhost:5000/;
|
| 50 |
# proxy_set_header Host $host;
|
| 51 |
# proxy_set_header X-Real-IP $remote_addr;
|
| 52 |
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 53 |
# proxy_set_header X-Forwarded-Proto $scheme;
|
| 54 |
+
# client_max_body_size 50M; # Adjust for Flask API if it also handles uploads
|
| 55 |
# }
|
| 56 |
}
|
| 57 |
}
|