<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Alex,<br><br>Thank you. This worked. Is it absolutely necessary to use a variable in the log file at the server {} section? Afterall... all of the logs of the listed countries are going to the same static filename.<br><br>--Mike<br><br><div><div id="SkyDrivePlaceholder"></div>> Date: Mon, 26 Mar 2012 02:29:38 +0300<br>> From: kolesen.a@gmail.com<br>> To: nginx@nginx.org<br>> Subject: Re: "access_log" directive is not allowed here in... how to do this  properly?<br>> <br>> > Hello !<br>> > <br>> > Iam trying to log the requests coming from a list of countries into a seperate<br>> > log file.. Iam using the config below... BUt iam getting this error:<br>> > <br>> > [emerg]: "access_log" directive is not allowed here in /etc/nginx/nginx.conf:55<br>> > configuration file /etc/nginx/nginx.conf test failed<br>> > <br>> > How could I accomplish what iam trying to do?<br>> > <br>> > Thanks!<br>> > <br>> > --Mike<br>> > <br>> > <br>> > http {<br>> >          ......<br>> >          .......<br>> > <br>> > geoip_country  /etc/nginx/GeoIP.dat;<br>> >       <br>> > map $geoip_country_code $log {<br>> >                         default       0;<br>> >                         CN 1; #"China"<br>> >                         RO 1; #"Romania"<br>> >                         IQ 1; #"Iraq"<br>> >                         IR 1; #"Iran<br>> >                         HK 1; #"Hong Kong"<br>> >                         IN 1; #"India"<br>> >                         }<br>> > <br>> >         server {<br>> >                 listen   80;<br>> >                 server_name  domain.com;<br>> >                 .....<br>> >                 .....<br>> >                 if ($log) { access_log  /root/access-selected-slim.log; }<br>> >                 location / { proxy_pass http://12.163.169.32:80/;  }<br>> > <br>> >                 }<br>> >      }<br>> > <br>> <br>> If you want to log queries from only the listed countries,<br>> you may write the following:<br>> <br>> http {<br>>          ......<br>>          .......<br>> <br>> geoip_country  /etc/nginx/GeoIP.dat;<br>> <br>> map $geoip_country_code $log {<br>>                         default       dev/null;<br>>                         CN root/access-selected-slim.log; #"China"<br>>                         RO root/access-selected-slim.log; #"Romania"<br>>                         IQ root/access-selected-slim.log; #"Iraq"<br>>                         IR root/access-selected-slim.log; #"Iran<br>>                         HK root/access-selected-slim.log; #"Hong Kong"<br>>                         IN root/access-selected-slim.log; #"India"<br>>                         }<br>> <br>>         server {<br>>                 listen   80;<br>>                 server_name  domain.com;<br>>                 .....<br>>                 .....   <br>>                 access_log /$log;<br>>                 location / { proxy_pass http://12.163.169.32:80/;  }<br>> <br>>                 }<br>>      }<br>> <br>> <br>> But note that access logs with variables in their names have limitatios. <br>> Refer to the http://wiki.nginx.org/HttpLogModule<br>> <br>> _______________________________________________<br>> nginx mailing list<br>> nginx@nginx.org<br>> http://mailman.nginx.org/mailman/listinfo/nginx<br></div>                                     </div></body>
</html>