# ============================================================================ # HF Spaces nginx config — single-container variant. # Difference from docker/nginx.conf: listens on 7860 (HF's expected port) and # proxies /api/* to 127.0.0.1:8000 (same-container uvicorn, not a compose # service name). # ============================================================================ server { listen 7860; server_name _; gzip on; gzip_types text/plain text/css application/json application/javascript application/xml+rss text/javascript image/svg+xml; gzip_min_length 1024; # Vite-fingerprinted assets — long cache. location /assets/ { root /var/www/html; expires 1y; add_header Cache-Control "public, immutable"; } # Proxy the API — uvicorn is running in the same container, port 8000. location /api/ { proxy_pass http://127.0.0.1:8000/; proxy_http_version 1.1; 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; proxy_connect_timeout 10s; proxy_read_timeout 120s; client_max_body_size 20m; } # SPA fallback — everything else goes to index.html. location / { root /var/www/html; index index.html; try_files $uri $uri/ /index.html; } }