gradio-streamlit-pg / nginx.conf
eienmojiki's picture
Create nginx.conf
8dfc591 verified
raw
history blame
1.51 kB
server {
listen 4444 default_server;
listen [::]:4444 default_server;
server_name _;
# 1. Định tuyến cho GRADIO (chạy trên 7860)
location /gradio {
rewrite /gradio/(.*) /$1 break;
proxy_pass http://localhost:7860;
# Cần các header sau cho cả Gradio và Streamlit
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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_cache_bypass $http_upgrade;
proxy_read_timeout 86400; # Tăng timeout cho các tác vụ ML
}
# 2. Định tuyến cho STREAMLIT (chạy trên 8501)
location /streamlit {
rewrite /streamlit/(.*) /$1 break;
proxy_pass http://localhost:8501;
# Cấu hình tương tự cho Streamlit
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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_cache_bypass $http_upgrade;
proxy_read_timeout 86400;
}
# 3. Yêu cầu root (/) chuyển hướng tới Gradio hoặc Streamlit
location / {
return 302 /gradio/; # Chọn một ứng dụng để làm mặc định
}
}