How to Block Country Traffic in cPanel
Posted about 4 months ago 4.3kWhy Block Countries
Use case: Reduce spam, attacks, or bandwidth from specific regions.
Using ConfigServer Firewall (CSF)
WHM → Plugins → ConfigServer Security & Firewall → Firewall Configuration → Country Code Lists.
Enable CC_DENY
Add country codes (e.g., CN, RU) separated by commas.
Alternative .htaccess Method
GeoIP Blocking Code
SetEnvIf GEOIP_COUNTRY_CODE CN BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE RU BlockCountry
Deny from env=BlockCountry
Common Blocked Countries Table
| Code | Country | Typical Reason |
|---|---|---|
| CN | China | High spam/attacks |
| RU | Russia | Bot traffic |
| UA | Ukraine | Mixed traffic |
| IN | India | Scraping |