Nginx 主动健康检查

问题描述 投票:0回答:1

我需要在 Nginx Plus 上实施主动 health_check。上游服务器代表一个 k8s 集群,我已经公开了 traefik 9000 健康端点。然而,健康检查报告它没有启动,因为 nginx 检查 https://k8s/ping 而不是 http://k8s/ping 在 https 上我得到 404,在 http 上得到 200。

如何告诉 Nginx 在 health_check 上使用 HTTP 而不是 https?

这是配置:

upstream k8s {
 zone k8s 64k;
 server server1:443
}

match probe {
 status 200;
 body ~ "OK";
}

# Server config
server {
 listen *.443 ssl;
 # server options placeholder

location / {
 proxy_pass https://k8s

 # headers placeholder

 health_check port=9000 uri=/ping match=probe;
}


}
kubernetes nginx nginx-reverse-proxy nginx-ingress nginx-config
1个回答
0
投票

您可以尝试以下 TCP Active Health 检查

stream {
   upstream k8s {
       zone k8s 64k;
       server backend1.example.com:9000 slow_start=30s;
       
   }
   match probe {
    send      "GET / HTTP/1.0\r\nHost: localhost\r\n\r\n";
    expect ~* "200 OK";
   }
   
   server {
       listen  9000;
       proxy_pass http://k8s;
       health_check match=probe interval=10 passes=2 fails=3;
       health_check_timeout 10s;
   }
}

您可以在官方文档

上阅读更多内容
© www.soinside.com 2019 - 2024. All rights reserved.