File size: 2,866 Bytes
760438e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # 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;
}
}
}
|