[alibaba/tengine]添加health check,报错check protocol http error with peer,求教

2024-01-30 210 views
4

tengine版本2.1.2.其中172.16.2.112为nginx服务器,172.16.2.110为tomcat服务器。 在不添加health check的时候,curl对应的chk.html可以正常返回页面。 添加health check之后,tengine的error log报check protocol http error with peer: 172.16.2.110:8080。

配置如下: upstream tomcat-1 { server 172.16.2.110:8080; check interval=3000 rise=2 fall=5 timeout=3000 type=http; check_http_send "GET /chk.html HTTP/1.1\r\n\r\n"; check_http_expect_alive http_2xx http_3xx; } server { listen 80; server_name 172.16.2.112; location / { index index.html; proxy_pass http://tomcat-1/testdb/; proxy_set_header Host $host:80; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Via "nginx"; break; } location /status { check_status;

access_log off;
}
    location /nginx_status {
        stub_status on;
        access_log   off;
}

}

报错如下: 2017/11/17 20:17:35 [error] 2451#0: check protocol http error with peer: 172.16.2.110:8080 2017/11/17 20:17:38 [error] 2451#0: check protocol http error with peer: 172.16.2.110:8080 2017/11/17 20:17:41 [error] 2451#0: check protocol http error with peer: 172.16.2.110:8080 2017/11/17 20:17:44 [error] 2451#0: check protocol http error with peer: 172.16.2.110:8080 2017/11/17 20:17:47 [error] 2451#0: check protocol http error with peer: 172.16.2.110:8080

谢谢支持。

回答

5

"GET /chk.html HTTP/1.1\r\n\r\n"; 注意你这个请求是没有Host,如果源站是实现完整的http服务器可以直接拒绝访问。建议用http/1.0或者添加Host:


这个报错信息是说明健康检查后端失败,可能是http协议异常,也可能是后端反回了非2xx和3xx的状态码

  • 调试可以通过:抓包确认,对比健康模块报错信息
  • 模拟这个请求访问后端用curl:"GET /chk.html HTTP/1.1\r\n\r\n"; 注意你这个请求是没有Host,如果源站是实现完整的http服务器可以直接拒绝访问。建议用http/1.0或者添加Host:
3

我这边已经修改了配置,将HTTP/1.1修改为http/1.0即可。同样,如果我这边需要使用http/1.1,那么我就需要配置Host头,这边Host头具体指的是什么?求教,谢谢解答

1

Host设置成你检查的后端能识别的即可

访问页面 http://test.com/uri,这里test.com一般就是HTTP请求中的Host头