Help! log phase is not executed due to r->count being non-zero

wangweixun nginx-forum at
Sat Oct 11 04:28:08 UTC 2014

Hey all,

I'm writing an authentication module that is structurally very similar to
It basically sends a subrequest to a service for auth. For testing, I put a
hello_world module module
behind it like:

location /hello_world {
     auth_request /auth;
     hello_world_string "Hello World!";

Everything works fine EXCEPT I found today that the log phase is not
excuted. I traced it down to ngx_http_close_request function in
ngx_http_request.c (as it calls ngx_http_free_request(r, rc); to excute log
handlers) where I found r->count = 2 so after r->count--; it's still
non-zero thus ngx_http_close_request simply returns. I did not touch request
count in my code.

Are we supposed to handle r->acount (either directly or through
ngx_http_finalize_request) when using subrequest? I didn't see the original
ngx_http_auth_request_module does so. If not, then why the request count is


Posted at Nginx Forum:,253906,253906#msg-253906

More information about the nginx mailing list