Looks good.
If I use the function multiple times, each time, for 1 country, like:Nginx does not support logical "or". Your best bet is to let the first if-section follow by another for the other country code. But: Nginx has issues with "if" in general, so it could lead to crashes. If is Evil… when used in location context | NGINX
if ($geoip2_data_country_code = "COUNTRY 1") {
return 403;
}
if ($geoip2_data_country_code = "COUNTRY 2") {
return 403;
}
@Peter DebikI do not know. How could I predict what will happen on your system? What keeps you from testing it?
Hi Peter, thanks for the info. Is there an further update on the ETA for this blocking?For the files I think the include is seen expanded, so you'd need to investigate further down in the included files. Regarding Nginx ModSecurity 3.0: This can be considered experimental. I am not sure if it indeed works with the rules. I think it should, but have not tested it.
Plesk is in the process or creating a general geo IP blocking feature, so maybe, if you want to save some time and it is not too urgent for you, it will be an option to just wait on that feature to be released. It is planned for 2023 and it is already being worked on.
I tied this after using some other guides. However when I used a vpn to access the website as a blocked country, the website still worked. Perversely, I could not access my 8443 panel from that country!@mudassarkhan you can use the Plesk firewall (if you run Plesk version 18.0.52 or newer) to block countries.
Hello @Peter Debik ,@othmaqsa Answered in your other thread: Question - Plesk Firewall
If you're talking about the same port number, the above mentioned list would block or allow all before the specific cases are processed. For that case you'll need to switch positions of the specific and general entries. If your entries are meant for different ports, the order is o.k.