Separate Log for Robot Page Access
Maxim Dounin
mdounin at mdounin.ru
Sat Feb 6 12:51:44 MSK 2010
Hello!
On Sat, Feb 06, 2010 at 12:31:41AM -0800, Wohbah wrote:
>
> To record robots in another log I have a boolean $is_robot. The variable is
> set correctly. But I can't use it. (nginx version 0.765-1)
>
> Why can I do
> if ( ... ) { ... access_log off; ... }
> but not
> if ( ... ) { ... access_log /var/log/nginx/robots.log; ... }
>
> When a robot visits, it gets error 500. No web page. Must I duplicate
> every location to change access_log settings? Here is the topmost one:
Yes, once you want to do something different you have to create
another location. Directive "if" does this implicitly, but it
fails to do it correctly in many cases.
> location / {
> access_log /var/log/nginx/access.log;
>
> ...much stuff I do not like duplicating, several lines...
>
> if ( $is_robot ~ T ) {
> access_log /var/log/nginx/robots.log;
> }
> try_files /maintenance.html $uri.html @phptry ;
> }
http://wiki.nginx.org/IfIsEvil
This won't work, see third example.
Maxim Dounin
More information about the nginx
mailing list