Nginx - 响应上游响应

Nginx - Reacting to Upstream Response

我使用 nginx 作为反向代理,通过外部提供商上传文件存储。 当我处理文件上传时,我需要在将响应返回给用户之前跟踪(在我的数据库中)上传是否成功。因此,我想使用 lua-nginx-module 中提供的 ngx.location.capture 方法与我的后端讨论请求的结果。由于我需要等待上游服务器的响应,所以我只能在 header_filter_by_lua 中发出捕获。不幸的是,我无法在 header_filter_by_lua 中进行任何对外通信。 ngx.location.capturengx.socket.*ngx.exec 仅在响应尚未到达时可用。

我如何对 nginx 中的上游响应做出反应?

我考虑过的其他方法:

感谢帮助:)

用于 /upload 位置: content_by_lua_fileresty.upload module