Article 6QTAJ Allow IP from one country + allow custom UserAgents from everywhere

Allow IP from one country + allow custom UserAgents from everywhere

by
Single Sig
from LinuxQuestions.org on (#6QTAJ)
Hi everyone. My question is about some custom blocking rules. I have a CentOS server where nginx serves many various domains. One of the domains should only be possible for visiting from Hungary. I know that if I had only this one domain on the server I would probably need to add something like this to IPtables (provided I have geoip module installed )

Code:iptables -A INPUT -m geoip --src-cc HU -p 443 -j ACCEPTBut I have many domains served by nginx so I guess that won't be it. I guess I need to add something to the .conf file of this website, but I have no idea. In addition to that, I would like to still allow Google and Bing search bots to reach this website from everywhere (by their "UserAgent" maybe). So the final result shuld be:

1. Allow IP's only from Hungary
2. Allow Google and Bing search bots' UserAgent from everywhere

Maybe some of you have ideas of how I can make it. Thank you!
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments