client-proxy: WARN "invalid host" spam from unroutable bare-IP Host requests (external probes)

未关闭 适合新手
#3,783 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@AdaAibaby 已经在做这个了。

开始于 2026年11月2日。

  • #3784 来自 @AdaAibaby —— 未关闭
  • #3785 来自 @AdaAibaby —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
backend

调研方向

该改动应放在 packages/shared/pkg/proxy/handler.go 中 handler() 的 ErrInvalidHost 分支里,该分支使用 host.go 中的 isLocalRequestHost 以及路由头检查。请先阅读这些辅助函数,然后为 Host 只是裸 IP、且没有 E2b-Sandbox-Id/E2b-Sandbox-Port 头的情况添加单元测试。完成标准是:该情况以 Debug 级别记录日志,格式错误的域名 Host 仍以 Warn 级别记录日志,并且 400 响应保持不变。开 PR 之前请先与维护者确认方向。

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

描述

Summary

client-proxy logs WARN "invalid host" for every inbound request whose Host is a bare IP address with no sandbox routing headers. On any proxy with a public endpoint these arrive continuously from external scanners, health probes, and stale clients still pointed at an old node IP, producing ~1 line/second of WARN noise that drowns real warnings.

Observed (client-proxy):

WARN  invalid host  {"service":"client-proxy","host":"118.196.30.209"}
WARN  invalid host  {"service":"client-proxy","host":"118.196.30.209"}
... (repeats every ~1s)
Why these are expected, not warnings

packages/shared/pkg/proxy/handler.go rejects the request with ErrInvalidHost and returns 400, which is correct. But a bare-IP Host cannot encode sandbox routing ({port}-{sandboxID}.{domain}) — as isLocalRequestHost in host.go documents, header-based routing is the only mechanism that can work for an IP host. So an IP Host that also carries no routing headers (E2b-Sandbox-Id / E2b-Sandbox-Port) is, by construction, unroutable. Rejecting it is the designed behavior; logging it at WARN on every hit just turns routine external traffic into log spam.

(Header-based routing for IP hosts — #2581 — is unaffected: an IP host with routing headers routes fine and never reaches this branch.)

Proposal

In the ErrInvalidHost branch of handler(), log at Debug when the host is a raw IP / localhost and no routing headers are present (isLocalRequestHost(r.Host) && !hasRoutingHeaders(r.Header)), and keep Warn for a genuinely suspect invalid host (a malformed domain host), which is rare and worth visibility. Status code stays 400 in both cases — this only changes log level, not behavior.

Environment

Reproduced on client-proxy main; the proxy sits behind a public ingress, so any internet host hitting the raw IP triggers it. Same code path in api (OpenAPI validator logs the same raw-IP / requests as 404 no matching operation), but the client-proxy WARN is the loudest.

Happy to send the PR (small, with a unit test) if the direction is acceptable.

主要语言
Go
星标
1.8k
派生
503
PR 合并指标
30 天内没有已合并 PR

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

e2b-dev/runtime 的其他 Issue

查看 e2b-dev/runtime 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

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