Welcome! Log In Create A New Profile

Advanced

post_action for specific requests only

February 20, 2014 03:32PM
Hi, i'm using post_action for remote logging. Logging all requests works great and efficient (4k req/s) but when I try to log only certain requests ngix becomes unstable (some connections hang and some weird errors occur). I've tried several ways to log specific requests only, but none of them works stable:
1) first way (if directive)
post_action @afterdownload;
location @afterdownload {
if ($foo) {
proxy_pass blah
}
}
2) second way (lua)
post_action @afterdownload;
location @afterdownload {
access_by_lua '
if ngx.var.blah then
ngx.location.capture(....)
end
ngx.exit(ngx.HTTP_OK)
';
}
3) third way (lua)
post_action /afterdownload;
location /afterdownload {
access_by_lua '
if ngx.var.blah then
ngx.location.capture(....)
end
ngx.exit(ngx.HTTP_OK)
';
}

First way involves evil 'if' so I assume it might not work smoothly, but what's wrong with the second or 3rd approach? It seems that if you remove ngx.exit() from the 3rd method it kinda works, but this way you get lots of 404 errors saying that /afterdownload is not found.
I've read here (http://mailman.nginx.org/pipermail/nginx/2012-November/036199.html) that post_action is executed in a context of main requests which explains a bit, but maybe there is a way for logging only specific requests (like setting post_action from lua maybe)?
Subject Author Posted

post_action for specific requests only

ahurkala February 20, 2014 03:32PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready