通常のHTTPアクセスとは思えない悪意のあるものは拒否しましょう。 .htaccess ファイルに以下のように記述することで実現することができます。 USER_AGENT が Wget ではじまるものを拒否する場合。 SetEnvIf User-Agent "^Wget" DENY_AGENT order allow,deny allow from all deny from env=DENY_AGENT VirtualHostで共通の設定を使用したい場合†deny-list.conf ファイルを作成する
SetEnvIf User-Agent "SemrushBot" deny_bot SetEnvIf User-Agent "BLEXBot" deny_bot SetEnvIf User-Agent "DomainCrawler" deny_bot <RequireAll> Require all granted Require not env deny_bot Require not ip 192.168.0.1 Require not ip 192.168.1.0/24 </RequireAll> VirtualHostの設定から deny-list.conf を Include する <VirtualHost *:443> ServerName sv1.example.com:443 DocumentRoot "/home/sv1/public_html" SSLEngine on SSLHonorCipherOrder on Header set Strict-Transport-Security "max-age=31536000; includeSubDomains" SSLProtocol -All +TLSv1 +TLSv1.1 +TLSv1.2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 SSLCertificateFile /etc/letsencrypt/live/sv1.example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/sv1.example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/sv1.example.com/chain.pem <Directory "/home/sv1/public_html"> Options FollowSymLinks AllowOverride ALL # Require all granted Include /usr/local/apache2/conf/extra/deny-list.conf </Directory> ErrorLog "logs/sv1_error_log" CustomLog "logs/sv1_access_log" combined </VirtualHost> 設定が有効になっているか確認 curl -A "test" -I https://sv1.example.com/ HTTP/1.1 200 OK curl -A "SemrushBot" -I https://sv1.example.com/ HTTP/1.1 403 Forbidden |