NGinx-计算特定网址格式的请求 [英] NGinx - Count requests for a particular URL pattern
问题描述
我想计算对特定网址格式的请求数量.不知道如何在NGinx中完成此操作.
I wanted to count the number of requests to a particular url pattern. Not sure how this is done in NGinx.
这可能吗:
当对网址格式的请求到来时,我们将首先处理该请求.然后NGinx异步地向服务器发送另一个请求,该请求对印象进行计数. NGinx不等待此请求的响应.
When an request to the url pattern comes, we serve that request first. Then NGinx makes another request asynchronously to a server which counts the impression. NGinx does not wait for the response of this request.
谢谢.
推荐答案
您可以在主请求完成后使用post_action指令来触发sub_request.
You can use the post_action directive to trigger a sub_request after the main request is complete.
对于您需要考虑的日志记录很有用.
Useful for the sort of logging you have in mind.
post_action指令已从Nginx文档中删除,尽管它似乎仍然有效,但不建议使用.买者自负!
The post_action directive has been removed from the Nginx documentation and while it still appears to work, usage is inadvisable. Caveat Emptor!
Nginx 1.13.4中引入的镜像模块 post_action指令.
The Mirror Module, introduced in Nginx 1.13.4, essentially replicates the post_action directive.
这篇关于NGinx-计算特定网址格式的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!