gpt4 book ai didi

node.js - 如何将 502 抛给 nginx?

转载 作者:搜寻专家 更新时间:2023-11-01 00:40:58 24 4
gpt4 key购买 nike

我有一个 nginx/nodejs 堆栈。

我的 nginx 配置为在我的 nodejs 进程关闭时提供静态 502 错误页面。

现在,我想让我的nodejs正常运行,偶尔向nginx抛出一个502,以在某些用户请求时触发静态502页面。我该怎么做?

我试图在我的 Node 进程中抛出一些错误而不捕获它们,但这导致错误堆栈被直接传递到客户端浏览器。

最佳答案

将此添加到您的代理配置中:

 proxy_intercept_errors on;

根据 the manual :

Determines whether proxied responses with codes greater than or equal to 300 should be passed to a client or be redirected to nginx for processing with the error_page directive. Default off

关于node.js - 如何将 502 抛给 nginx?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34621729/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com