You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ngrok.yml的endpoint配置中添加请求头(Ngrok v3)

解决Ngrok v3 Endpoint配置中Host Header的问题

正确配置方式一(直接对应原tunnel的host_header)

原来tunnels中的host_header配置,在endpoints模式下可以直接映射到upstream节点下的host_header字段,配置如下:

endpoints:
  - name: myendpoint
    upstream:
      url: http://localhost:3000
      host_header: localhost

正确配置方式二(使用请求头添加)

如果要通过请求头添加的方式实现,需要注意字段名是复数形式的request_headers,并且作为endpoint的直接子节点,而非嵌套在upstream内:

endpoints:
  - name: myendpoint
    upstream:
      url: http://localhost:3000
    request_headers:
      add:
        Host: localhost

报错原因说明

你之前遇到的field request_header not found错误,主要有两个原因:

  • 字段名写错:应该是复数的request_headers,而非单数的request_header
  • 位置错误:request_headers必须作为endpoint的直接子节点,不能嵌套在upstream或其他节点中

内容的提问来源于stack exchange,提问作者Jamie Humphries

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 01:22:03