NGINX 健康检查需要上游

标签 nginx nginx-location

我有一个位置,如:

location / {
set $api_name "Web";

proxy_intercept_errors on;

set $upstream upstream_a;

if ( $kms_in_cookie != "not_set" ) {
    set $upstream $kms_in_cookie;
}

if ( $upstream_in_cookie != "not_set" ) {
    set $upstream $upstream_in_cookie;
}

if ($cookie_zak != "") {
    set $upstream upstream_b;
}

proxy_pass http://$upstream;

health_check uri=/healthcheck  interval=30 fails=3 passes=3;}

一旦我重新启动我的 NGINX,它就失败了:
nginx: [emerg] health check requires an upstream in

有没有人对此有任何想法?这个错误是什么意思?

最佳答案

我遇到过同样的问题。通过对其进行试验,问题似乎是 proxy_pass 中的变量名称。指示。如果您使用有效上游的名称,问题将得到解决。

显然,您正在尝试根据某些请求元数据来引导流量,而上述建议对此无济于事。你的情况并不少见,所以我希望这能奏效。看起来像是 nginx 中的一个错误,或者至少是文档中的一个空白。

关于NGINX 健康检查需要上游,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51837920/

相关文章:

nginx - 如何在 https NGINX 中将非 www 重定向到 www

docker - nginx入口将流量发送到pod中的nginx,但不返回 Assets

nginx - 在 nginx 位置指令中向响应添加 header

bash - configMap 的文件名在 Pod 中显示为 env

ssl - Nginx SSL 证书路径格式

php - Ubuntu server 20.4 nginx 在任何 php 页面上总是返回 404,html 完美运行

docker - 如何使用NGINX将请求转发到Docker Microservice

docker - 在 Alpine Linux 下编辑/隐藏 Nginx Server header

.htaccess - 将 Kohana 从 Apache 迁移到 NginX

regex - 如何在该位置使用Nginx Regex