Welcome! Log In Create A New Profile

Advanced

Re: "access_log" directive is not allowed here in... how to do this properly?

Alexander Kolesen
March 25, 2012 07:30PM
> Hello !
>
> Iam trying to log the requests coming from a list of countries into a seperate
> log file.. Iam using the config below... BUt iam getting this error:
>
> [emerg]: "access_log" directive is not allowed here in /etc/nginx/nginx.conf:55
> configuration file /etc/nginx/nginx.conf test failed
>
> How could I accomplish what iam trying to do?
>
> Thanks!
>
> --Mike
>
>
> http {
> ......
> .......
>
> geoip_country /etc/nginx/GeoIP.dat;
>
> map $geoip_country_code $log {
> default 0;
> CN 1; #"China"
> RO 1; #"Romania"
> IQ 1; #"Iraq"
> IR 1; #"Iran
> HK 1; #"Hong Kong"
> IN 1; #"India"
> }
>
> server {
> listen 80;
> server_name domain.com;
> .....
> .....
> if ($log) { access_log /root/access-selected-slim.log; }
> location / { proxy_pass http://12.163.169.32:80/; }
>
> }
> }
>

If you want to log queries from only the listed countries,
you may write the following:

http {
......
.......

geoip_country /etc/nginx/GeoIP.dat;

map $geoip_country_code $log {
default dev/null;
CN root/access-selected-slim.log; #"China"
RO root/access-selected-slim.log; #"Romania"
IQ root/access-selected-slim.log; #"Iraq"
IR root/access-selected-slim.log; #"Iran
HK root/access-selected-slim.log; #"Hong Kong"
IN root/access-selected-slim.log; #"India"
}

server {
listen 80;
server_name domain.com;
.....
.....
access_log /$log;
location / { proxy_pass http://12.163.169.32:80/; }

}
}


But note that access logs with variables in their names have limitatios.
Refer to the http://wiki.nginx.org/HttpLogModule

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

"access_log" directive is not allowed here in... how to do this properly?

Micheal Wolfskill March 25, 2012 03:22PM

Re: "access_log" directive is not allowed here in... how to do this properly?

Francis Daly March 25, 2012 06:34PM

RE: "access_log" directive is not allowed here in... how to do this properly?

Micheal Wolfskill March 25, 2012 06:44PM

Re: "access_log" directive is not allowed here in... how to do this properly?

Francis Daly March 25, 2012 07:10PM

RE: "access_log" directive is not allowed here in... how to do this properly?

Micheal Wolfskill March 25, 2012 07:16PM

Re: "access_log" directive is not allowed here in... how to do this properly?

Francis Daly March 25, 2012 07:22PM

RE: "access_log" directive is not allowed here in... how to do this properly?

Micheal Wolfskill March 25, 2012 07:42PM

Re: "access_log" directive is not allowed here in... how to do this properly?

Francis Daly March 25, 2012 08:06PM

Re: "access_log" directive is not allowed here in... how to do this properly?

Alexander Kolesen March 25, 2012 07:30PM

RE: "access_log" directive is not allowed here in... how to do this properly?

Micheal Wolfskill March 25, 2012 08:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready