Spaces:
Sleeping
Sleeping
Akshar2325 commited on
Commit ·
5231ffd
1
Parent(s): fe68b94
fix(nginx): Improve proxy buffering and WebSocket support
Browse files- Change error log level from warn to error for cleaner output
- Disable proxy buffering and request buffering in both console and S3 API locations to support WebSocket connections
- Add explicit WebSocket upgrade headers (Upgrade and Connection: upgrade) to console location
- Reorganize location block comments with visual separators for better readability
- Improve inline documentation for proxy configuration and path rewriting logic
- Ensure consistent proxy header configuration across all upstream locations
- nginx.conf +18 -11
nginx.conf
CHANGED
|
@@ -12,11 +12,10 @@ http {
|
|
| 12 |
sendfile on;
|
| 13 |
keepalive_timeout 65;
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
error_log /dev/stderr
|
| 17 |
access_log off;
|
| 18 |
|
| 19 |
-
# Upstreams
|
| 20 |
upstream minio_api {
|
| 21 |
server 127.0.0.1:9000;
|
| 22 |
}
|
|
@@ -25,38 +24,46 @@ http {
|
|
| 25 |
server 127.0.0.1:9001;
|
| 26 |
}
|
| 27 |
|
| 28 |
-
# Single server for the Space
|
| 29 |
server {
|
| 30 |
listen 7860 default_server;
|
| 31 |
server_name _;
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
# Browser requests /, /styles/*, /static/*, /images/*, etc.
|
| 35 |
location / {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
proxy_http_version 1.1;
|
| 37 |
proxy_set_header Host $host;
|
| 38 |
proxy_set_header X-Real-IP $remote_addr;
|
| 39 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 40 |
proxy_set_header X-Forwarded-Proto $scheme;
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
chunked_transfer_encoding off;
|
| 43 |
|
| 44 |
proxy_pass http://minio_console;
|
| 45 |
}
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
# e.g. https://lucifer925-minio-storage.hf.space/s3/mybucket/myobject
|
| 49 |
location /s3/ {
|
|
|
|
|
|
|
|
|
|
| 50 |
proxy_http_version 1.1;
|
| 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 |
proxy_set_header Connection "";
|
|
|
|
| 56 |
chunked_transfer_encoding off;
|
| 57 |
|
| 58 |
-
#
|
| 59 |
-
# /s3/mybucket/file → /mybucket/file on MinIO API
|
| 60 |
proxy_pass http://minio_api/;
|
| 61 |
}
|
| 62 |
}
|
|
|
|
| 12 |
sendfile on;
|
| 13 |
keepalive_timeout 65;
|
| 14 |
|
| 15 |
+
# Only show real errors
|
| 16 |
+
error_log /dev/stderr error;
|
| 17 |
access_log off;
|
| 18 |
|
|
|
|
| 19 |
upstream minio_api {
|
| 20 |
server 127.0.0.1:9000;
|
| 21 |
}
|
|
|
|
| 24 |
server 127.0.0.1:9001;
|
| 25 |
}
|
| 26 |
|
|
|
|
| 27 |
server {
|
| 28 |
listen 7860 default_server;
|
| 29 |
server_name _;
|
| 30 |
|
| 31 |
+
# ============ MinIO CONSOLE (root /) ============
|
|
|
|
| 32 |
location / {
|
| 33 |
+
# disable buffering so websockets work nicely
|
| 34 |
+
proxy_buffering off;
|
| 35 |
+
proxy_request_buffering off;
|
| 36 |
+
|
| 37 |
proxy_http_version 1.1;
|
| 38 |
proxy_set_header Host $host;
|
| 39 |
proxy_set_header X-Real-IP $remote_addr;
|
| 40 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 41 |
proxy_set_header X-Forwarded-Proto $scheme;
|
| 42 |
+
|
| 43 |
+
# *** WebSocket headers ***
|
| 44 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 45 |
+
proxy_set_header Connection "upgrade";
|
| 46 |
+
|
| 47 |
chunked_transfer_encoding off;
|
| 48 |
|
| 49 |
proxy_pass http://minio_console;
|
| 50 |
}
|
| 51 |
|
| 52 |
+
# ============ MinIO S3 API (/s3/*) ============
|
|
|
|
| 53 |
location /s3/ {
|
| 54 |
+
proxy_buffering off;
|
| 55 |
+
proxy_request_buffering off;
|
| 56 |
+
|
| 57 |
proxy_http_version 1.1;
|
| 58 |
proxy_set_header Host $host;
|
| 59 |
proxy_set_header X-Real-IP $remote_addr;
|
| 60 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 61 |
proxy_set_header X-Forwarded-Proto $scheme;
|
| 62 |
proxy_set_header Connection "";
|
| 63 |
+
|
| 64 |
chunked_transfer_encoding off;
|
| 65 |
|
| 66 |
+
# strip /s3/ prefix
|
|
|
|
| 67 |
proxy_pass http://minio_api/;
|
| 68 |
}
|
| 69 |
}
|