如何处理Nginx内部请求或不请求

我使用nginx作为代理服务器,只需设置 proxy_intercept_errors on; 和 error_page指令 error_page 400 /400.html; location = /400.html { root /path/to/error; }

因此,作为servlet的后端服务器有时会像 HttpServletResponse.sendError(404);那样发送错误,该请求可能会返回到nginx并重定向到400.html。

在这种情况下,我需要处理内部重定向到400的情况。

我的问题是,我使用了一个lua脚本,该脚本检查所有收入的请求的一些内容,因此当发生内部请求时,我需要告诉我的lua跳过检查。

是否有可能识别内部请求?

点赞
用户8667197
用户8667197

下面的 ngx.req.is_internal() 是答案。

https://github.com/openresty/lua-nginx-module#ngxreqis_internal

2021-05-19 15:17:54