Greetings!
In my neverending struggle with comment-spam, I've decided to use GeoIP to block access from several countries. So far, I have only been able to block [b]all[/b] methods with the following piece of config:
[code]geoip_country /etc/nginx/GeoIP.dat;
if ($geoip_country_code ~ "BR|CN|KR") {
return 403;
}[/code]
This works pretty well, but I think it is like killing ants with a nuclear missile. I would like the GeoIP checks to be triggered [b]only[/b] when the POST method is used. This way people still have access to the content of the site.
I have tried a few options that seemed somewhat logical to me:
[code]if ($request_method ~ ^POST$ && $geoip_country_code ~ "BR|CN|KR") {[/code]
and
[code]
if ($request_method ~ ^POST$ ) {
if ($geoip_country_code ~ "BR|CN|KR") {
return 403;
}
}[/code]
Neither worked.
Is what I am trying to do possible at all? If so, how do I achieve this?
Thanks,
Eelco