Dstack-TEE / Dstack-TEE/dstack-examples

dstack-ingress: add WebSocket proxy support

Đang mở
#87 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
27
Fork
26
Merge trung bình
1 giờ 25 phút
Pull request đã merge (30 ngày)
7

Mô tả

The `kvin/dstack-ingress:wildcard` image generates its nginx config via `setup_nginx_conf()` in the entrypoint, but the `location /` block is missing WebSocket upgrade headers. Without these, any WebSocket service behind dstack-ingress gets HTTP 200 instead of 101 Upgrade.

**Suggested fix**: add these three lines to the `location /` block in `setup_nginx_conf()`:

```nginx
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
```

This is safe for mixed HTTP + WebSocket traffic. `$http_upgrade` is empty for regular HTTP requests, and upstreams ignore `Connection: upgrade` when there's no valid `Upgrade` value. `proxy_http_version 1.1` is strictly better than the default 1.0 (also enables keepalive). This is the standard nginx pattern recommended in the [nginx WebSocket docs](https://nginx.org/en/docs/http/websocket.html).

**Current workaround**: override `command` in docker-compose to patch the generated config before starting nginx:

```yaml
command:
- bash
- -c
- |
sed -i '/proxy_pass/a\ proxy_http_version 1.1;\n proxy_set_header Upgrade $$http_upgrade;\n proxy_set_header Connection "upgrade";' /etc/nginx/conf.d/default.conf
exec nginx -g "daemon off;"
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.