Nginx主动健康检查

n3ipq98p  于 5个月前  发布在  Nginx
关注(0)|答案(1)|浏览(57)

我需要在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;
}

}

字符串

rryofs0p

rryofs0p1#

您可以尝试以下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;
   }
}

字符串
您可以在official docs上阅读更多内容

相关问题