Welcome! Log In Create A New Profile

Advanced

access log ONLY for a specific agent string???

Posted by jost 
access log ONLY for a specific agent string???
August 28, 2013 07:37AM
Cant figure out how to do this.

I want my access log to only log entries that come from an agent containing the string "wordone wordtwo wordthree" etc

Anyway to do this?
Re: access log ONLY for a specific agent string???
August 28, 2013 09:29AM
Ive played around with this:

if ($http_user_agent ~* (bot) ) {
set $crawler 'yes';
}
location / {
if ($crawler = 'yes') {
access_log /var/log/bots.log;
access_log on;
}
}



Just doesnt work. :(
Nothing appears in the log file



Edited 1 time(s). Last edit at 08/28/2013 09:34AM by jost.
Re: access log ONLY for a specific agent string???
August 28, 2013 10:23AM
Got it working!

Was a location block problem.

I deleted the location / block

and move this part
if ($crawler = 'yes') {
access_log /var/log/bots.log;
access_log on;

to my fastcgi processing block
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 209
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready