Blockieren des Zugriffs aus einem bestimmten Land

Version vom 11. Juni 2021, 17:30 Uhr von Rb (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „category:ueberarbeiten '''Dieser Artikel befindet sich zur Zeit in Bearbeitung''' Falls man gewisse Länder aufgrund von vielen Bot-Aktivitäten sperren…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)


Dieser Artikel befindet sich zur Zeit in Bearbeitung

Falls man gewisse Länder aufgrund von vielen Bot-Aktivitäten sperren möchte, kann man hierbei die Ländererkennung bei apache2 in der .htaccess verwenden. Hierzu braucht man nur ein paar Zeilen mit dem jeweiligen Land (siehe hier), was man sperren möchte, einfügen:

Mithilfe von mod_maxminddb in der .htaccess:

1. Beispiel: China

<IfModule mod_maxminddb.c>
MaxMindDBEnable On
MaxMindDBFile COUNTRY_DB /usr/local/share/maxminddb/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE COUNTRY_DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE ^(CN) BlockCountry
Deny from env=BlockCountry
</IfModule>

2. Beispiel: Russland & China

<IfModule mod_maxminddb.c>
MaxMindDBEnable On
MaxMindDBFile COUNTRY_DB /usr/local/share/maxminddb/GeoLite2-Country.mmdb
MaxMindDBEnv MM_COUNTRY_CODE COUNTRY_DB/country/iso_code
SetEnvIf MM_COUNTRY_CODE ^(RU|CN) BlockCountry
Deny from env=BlockCountry
</IfModule>

Mithilfe von mod_geoip in der .htaccess:

1. Beispiel: China

GeoIPEnable On   
SetEnvIf GEOIP_COUNTRY_CODE CN DenyCountry 
Allow from all 
Deny from env=DenyCountry

1. Beispiel: Russland & China

GeoIPEnable On   
SetEnvIf GEOIP_COUNTRY_CODE CN DenyCountry 
SetEnvIf GEOIP_COUNTRY_CODE RU DenyCountry 
Allow from all 
Deny from env=DenyCountry