I am using nginx and I have installed geoip-database-contrib package to block access to /wp-admin location from all countries except some preferred.
location /wp-admin {
if ($allowed_country = no) {
return 403;
}
}
It works fine when trying to open this page in browser. But still I can see in access.log many POST requests and in worpdress logs failed login requests from rejected countries. Is possible to use geoip-database-contrib module also for POST requests?
I tried:
location /wp-admin {
if ($allowed_country = no) {
deny all;
}
}
but after reload nginx doesnt start at all. Do you have any ideas, how to block all requests only for location /wp-admin ? I don't want to block traffic at firewall level, because all countries should have access to web, but I want to limit requests to admin.
I know that I could permit request only for some IP addresses, but I need to access admin from more places where I have dyn. assigned IP.
Thank you very much for your ideas.