gazet / nginx.conf
Daniel Wiesmann
Expose the API alongside the Streamlit demo in the HF Space via nginx
7cc374f
Raw
History Blame Contribute Delete
1.32 kB
worker_processes auto;
pid /tmp/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 1024;
}
http {
access_log /var/log/nginx/access.log;
upstream api {
server 127.0.0.1:8000;
}
upstream streamlit {
server 127.0.0.1:8501;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 7860;
server_name _;
location /api/ {
proxy_pass http://api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_http_version 1.1;
# /search/stream emits NDJSON incrementally; buffering would hold it
# until the response completes, defeating the point of streaming.
proxy_buffering off;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
location / {
proxy_pass http://streamlit;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
}
}