Dstack-TEE / Dstack-TEE/dstack-examples

dstack-ingress: add WebSocket proxy support

未关闭 适合新手
#87 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
27
派生
26
平均合并
1 小时 25 分钟
30 天内合并 PR
7

描述

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;"
```

贡献指南

打开贡献指南

调研方向

找到包含 setup_nginx_conf() 的入口点,并检查它如何生成 nginx location / 块。在那里添加所请求的 WebSocket 代理设置,然后验证 WebSocket 请求会收到 101 Upgrade 响应,同时常规 HTTP 流量仍能正常工作。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, nginx
领域
infrastructure
Issue 类型
功能
难度
2/5
预计耗时
1-3 小时
活跃度
冷清
描述清晰度
描述清楚
新手友好度
76/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。