Spaces:
Sleeping
Sleeping
Create nginx.conf
Browse files- nginx.conf +43 -0
nginx.conf
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
server {
|
| 2 |
+
listen 4444 default_server;
|
| 3 |
+
listen [::]:4444 default_server;
|
| 4 |
+
|
| 5 |
+
server_name _;
|
| 6 |
+
|
| 7 |
+
# 1. Định tuyến cho GRADIO (chạy trên 7860)
|
| 8 |
+
location /gradio {
|
| 9 |
+
rewrite /gradio/(.*) /$1 break;
|
| 10 |
+
proxy_pass http://localhost:7860;
|
| 11 |
+
|
| 12 |
+
# Cần các header sau cho cả Gradio và Streamlit
|
| 13 |
+
proxy_http_version 1.1;
|
| 14 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 15 |
+
proxy_set_header Connection 'upgrade';
|
| 16 |
+
proxy_set_header Host $host;
|
| 17 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 18 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 19 |
+
proxy_cache_bypass $http_upgrade;
|
| 20 |
+
proxy_read_timeout 86400; # Tăng timeout cho các tác vụ ML
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
# 2. Định tuyến cho STREAMLIT (chạy trên 8501)
|
| 24 |
+
location /streamlit {
|
| 25 |
+
rewrite /streamlit/(.*) /$1 break;
|
| 26 |
+
proxy_pass http://localhost:8501;
|
| 27 |
+
|
| 28 |
+
# Cấu hình tương tự cho Streamlit
|
| 29 |
+
proxy_http_version 1.1;
|
| 30 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 31 |
+
proxy_set_header Connection 'upgrade';
|
| 32 |
+
proxy_set_header Host $host;
|
| 33 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 34 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 35 |
+
proxy_cache_bypass $http_upgrade;
|
| 36 |
+
proxy_read_timeout 86400;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
# 3. Yêu cầu root (/) chuyển hướng tới Gradio hoặc Streamlit
|
| 40 |
+
location / {
|
| 41 |
+
return 302 /gradio/; # Chọn một ứng dụng để làm mặc định
|
| 42 |
+
}
|
| 43 |
+
}
|