小编Mar*_*ark的帖子

Nginx 根据上游响应代码返回 444

我有 nginx 设置可以使用代理传递传递给上游。上游被写入以在某些请求上返回 502 http 响应,而不是返回 502 和所有标头,我希望 nginx 识别它并返回 444,因此没有返回任何内容。这可能吗?

我还尝试在任何 50x 错误时返回 444,但它也不起作用。

location / {
    return 444;
}


location ^~ /service/v1/ {
    proxy_pass http://127.0.0.1:3333;
    proxy_next_upstream error timeout http_502;
    error_page  500 502 503 504  /50x.html;
}

location = /50x.html {
    return 444;
}

error_page  404              /404.html;
location = /404.html {
    return 444;
}
Run Code Online (Sandbox Code Playgroud)

nginx

5
推荐指数
1
解决办法
7673
查看次数

标签 统计

nginx ×1