Debdeep30's picture
Upload frontend + backend
760438e verified
Raw
History Blame
2.87 kB
# Droplet nginx config
# Serves React at port 80; proxies Gradio API to localhost:7860
# Drop this file at /etc/nginx/sites-available/lumi and symlink to sites-enabled/
worker_processes 1;
error_log /var/log/nginx/error.log warn;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80 default_server;
# React build is deployed to /var/www/lumi/
root /var/www/lumi;
index index.html;
# ── Gradio new REST API (gradio-client v2.x) ──────────────────────
location /gradio_api/ {
proxy_pass http://127.0.0.1:7860/gradio_api/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_buffering off;
proxy_read_timeout 300s;
}
# ── Gradio legacy queue / predict ─────────────────────────────────
location /queue/ {
proxy_pass http://127.0.0.1:7860/queue/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_buffering off;
proxy_read_timeout 300s;
}
location /api/ {
proxy_pass http://127.0.0.1:7860/api/;
proxy_http_version 1.1;
proxy_buffering off;
proxy_read_timeout 300s;
}
location /run/ {
proxy_pass http://127.0.0.1:7860/run/;
proxy_http_version 1.1;
proxy_buffering off;
proxy_read_timeout 300s;
}
location = /upload {
proxy_pass http://127.0.0.1:7860/upload;
proxy_buffering off;
}
location = /info { proxy_pass http://127.0.0.1:7860/info; }
location = /config { proxy_pass http://127.0.0.1:7860/config; }
# ── Gradio file serving (/file=/absolute/path) ────────────────────
location ~* "^/file=" {
proxy_pass http://127.0.0.1:7860;
proxy_buffering off;
proxy_read_timeout 60s;
}
# ── React SPA ─────────────────────────────────────────────────────
location / {
try_files $uri $uri/ /index.html;
}
}
}