Spaces:
Sleeping
Sleeping
Update nginx.conf
Browse files- nginx.conf +10 -23
nginx.conf
CHANGED
|
@@ -8,14 +8,8 @@ server {
|
|
| 8 |
# 1. Định tuyến cho GRADIO (URL Gốc / Trang chủ)
|
| 9 |
# ------------------------------------------------
|
| 10 |
|
| 11 |
-
# Mọi thứ (trừ /streamlit) sẽ được chuyển đến Gradio.
|
| 12 |
location / {
|
| 13 |
-
#
|
| 14 |
-
# Trong trường hợp này, X-Forwarded-Prefix không cần thiết, nhưng không hại.
|
| 15 |
-
proxy_set_header X-Forwarded-Prefix /;
|
| 16 |
-
|
| 17 |
-
# Proxy_pass đến cổng 7860 (Gradio/FastAPI)
|
| 18 |
-
# Dấu / ở cuối proxy_pass rất quan trọng
|
| 19 |
proxy_pass http://localhost:7860/;
|
| 20 |
|
| 21 |
# Cấu hình WebSockets
|
|
@@ -23,38 +17,31 @@ server {
|
|
| 23 |
proxy_set_header Upgrade $http_upgrade;
|
| 24 |
proxy_set_header Connection 'upgrade';
|
| 25 |
|
| 26 |
-
# Headers chuẩn
|
| 27 |
proxy_set_header Host $host;
|
| 28 |
proxy_set_header X-Real-IP $remote_addr;
|
| 29 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 30 |
-
|
| 31 |
-
|
| 32 |
proxy_read_timeout 86400;
|
| 33 |
proxy_redirect off;
|
| 34 |
}
|
| 35 |
|
| 36 |
|
| 37 |
# ------------------------------------------------
|
| 38 |
-
# 2. Xử lý Chuyển hướng BẮT BUỘC cho
|
| 39 |
# ------------------------------------------------
|
| 40 |
|
| 41 |
-
#
|
| 42 |
location = /streamlit {
|
| 43 |
return 302 /streamlit/;
|
| 44 |
}
|
| 45 |
|
| 46 |
-
|
| 47 |
-
# ------------------------------------------------
|
| 48 |
-
# 3. Định tuyến cho STREAMLIT (Endpoint /streamlit/)
|
| 49 |
-
# ------------------------------------------------
|
| 50 |
-
|
| 51 |
location /streamlit/ {
|
| 52 |
-
#
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
# KHÔNG DÙNG DẤU / Ở CUỐI: Chuyển tiếp nguyên văn mọi thứ bắt đầu bằng /streamlit/
|
| 56 |
proxy_pass http://localhost:8501;
|
| 57 |
-
|
| 58 |
# Cấu hình WebSockets
|
| 59 |
proxy_http_version 1.1;
|
| 60 |
proxy_set_header Upgrade $http_upgrade;
|
|
@@ -64,7 +51,7 @@ server {
|
|
| 64 |
proxy_set_header Host $host;
|
| 65 |
proxy_set_header X-Real-IP $remote_addr;
|
| 66 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 67 |
-
|
| 68 |
|
| 69 |
proxy_read_timeout 86400;
|
| 70 |
proxy_redirect off;
|
|
|
|
| 8 |
# 1. Định tuyến cho GRADIO (URL Gốc / Trang chủ)
|
| 9 |
# ------------------------------------------------
|
| 10 |
|
|
|
|
| 11 |
location / {
|
| 12 |
+
# Đảm bảo Nginx cắt URL gốc và chuyển tiếp tới /
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
proxy_pass http://localhost:7860/;
|
| 14 |
|
| 15 |
# Cấu hình WebSockets
|
|
|
|
| 17 |
proxy_set_header Upgrade $http_upgrade;
|
| 18 |
proxy_set_header Connection 'upgrade';
|
| 19 |
|
| 20 |
+
# Headers chuẩn (RẤT QUAN TRỌNG CHO HF SPACES)
|
| 21 |
proxy_set_header Host $host;
|
| 22 |
proxy_set_header X-Real-IP $remote_addr;
|
| 23 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 24 |
+
proxy_set_header X-Forwarded-Proto $scheme; # Cần cho HF HTTPS
|
| 25 |
+
|
| 26 |
proxy_read_timeout 86400;
|
| 27 |
proxy_redirect off;
|
| 28 |
}
|
| 29 |
|
| 30 |
|
| 31 |
# ------------------------------------------------
|
| 32 |
+
# 2. Xử lý Chuyển hướng BẮT BUỘC và Định tuyến cho STREAMLIT
|
| 33 |
# ------------------------------------------------
|
| 34 |
|
| 35 |
+
# Buộc chuyển hướng /streamlit -> /streamlit/
|
| 36 |
location = /streamlit {
|
| 37 |
return 302 /streamlit/;
|
| 38 |
}
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
location /streamlit/ {
|
| 41 |
+
# KHÔNG DÙNG DẤU / Ở CUỐI TRONG proxy_pass
|
| 42 |
+
# Vì Streamlit đã được cấu hình baseUrlPath để tự xử lý đường dẫn con
|
|
|
|
|
|
|
| 43 |
proxy_pass http://localhost:8501;
|
| 44 |
+
|
| 45 |
# Cấu hình WebSockets
|
| 46 |
proxy_http_version 1.1;
|
| 47 |
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
| 51 |
proxy_set_header Host $host;
|
| 52 |
proxy_set_header X-Real-IP $remote_addr;
|
| 53 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 54 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 55 |
|
| 56 |
proxy_read_timeout 86400;
|
| 57 |
proxy_redirect off;
|