如何在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
相关产品推荐
相关产品推荐

