萝卜L

导航

代理Proxy 502 Bad Gateway 错误 Request Headers Host字段 缺失造成 (no connection could be made because the target machine actively refused it) V1

异常

  • 程序中(使用Request)开启代理(Proxy),访问某网页,返回"502 Bad Gateway"。
  • 对应的,代理(Clash)中记录(Logs)显示"no connection could be made because the target machine actively refused it"。
  • 程序关闭代理(访问此网页),正常。
    使用浏览器开启代理访问此网页),正常。
    程序(开启代理)访问另一网页(baidu),正常。(代理记录中为直连(Direct))

原因

  • 程序中Request的Headers参数缺少Host字段。

    所有HTTP/1.1 请求报文中必须包含一个Host头字段。对于缺少Host头或者含有超过一个Host头的HTTP/1.1 请求,可能会收到400(Bad Request)状态码。

    自:Host - HTTP | MDN (mozilla.org)

posted on 2022-05-20 16:56  萝卜L  阅读(1389)  评论(0编辑  收藏  举报