Kubernetes HTTP运行状况检查失败,并显示“ http:服务器向HTTPS客户端提供了HTTP响应”

时间:2019-07-26 18:13:48

标签: kubernetes kubernetes-health-check

这发生在我做了以下事情之后:

    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

在Apache中,实际上基于HTTP标头执行301重定向。

此卷曲启动了恶魔:

curl -vk -H 'Host: example.com' 172.17.0.2/api/v1/ping
* Expire in 0 ms for 6 (transfer 0x1af6470)
*   Trying 172.17.0.2...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x1af6470)
* Connected to 172.17.0.2 (172.17.0.2) port 80 (#0)
> GET /api/v1/ping HTTP/1.1
> Host: example.com
> User-Agent: curl/7.64.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Date: Fri, 26 Jul 2019 18:14:09 GMT
< Server: Apache/2.4.38 (Debian)
< Location: https://example.com/api/v1/ping
< Content-Length: 239
< Content-Type: text/html; charset=iso-8859-1
< 
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://example.com/api/v1/ping">here</a>.</p>
</body></html>
* Connection #0 to host 172.17.0.2 left intact

为什么此Pod出现此错误?

  Warning  Unhealthy  99m (x7 over 100m)  kubelet, minikube  Readiness probe failed: Get https://172.17.0.9:80/api/v1/ping: http: server gave HTTP response to HTTPS client

1 个答案:

答案 0 :(得分:0)

可能只是看到301重定向到https ...错误有点误导,因为它甚至没有尝试HTTPS请求...我认为它不会跟随301,而是在不返回时失败200 ...