Ban ChatGPT user agents

This commit is contained in:
Alex Cabal 2025-03-24 13:59:13 -05:00
parent ceccd1431e
commit 8a3a05a264
2 changed files with 10 additions and 2 deletions

View file

@ -160,7 +160,11 @@ Define conf_rewrite_root ${web_root}/config/apache/rewrites
# Such services will have the custom `X-Forwarded-For` HTTP header set. # Such services will have the custom `X-Forwarded-For` HTTP header set.
RewriteCond %{HTTP:X-Forwarded-For} . [OR] RewriteCond %{HTTP:X-Forwarded-For} . [OR]
RewriteCond %{HTTP:CF-Connecting-IP} . RewriteCond %{HTTP:CF-Connecting-IP} .
RewriteRule ^.*$ - [F,L] RewriteRule ^ - [L,F]
# ChatGPT has DDOS'd sites before. Short-circuit any ChatGPT requests to HTTP 429.
RewriteCond %{HTTP_USER_AGENT} ChatGPT-User
RewriteRule ^ - [L,R=429]
# In RewriteCond, RewriteRule gets evaluated BEFORE RewriteCond, so $1 refers to the first # In RewriteCond, RewriteRule gets evaluated BEFORE RewriteCond, so $1 refers to the first
# match in RewriteRule # match in RewriteRule

View file

@ -142,7 +142,11 @@ Define conf_rewrite_root ${web_root}/config/apache/rewrites
# Such services will have the custom `X-Forwarded-For` HTTP header set. # Such services will have the custom `X-Forwarded-For` HTTP header set.
RewriteCond %{HTTP:X-Forwarded-For} . [OR] RewriteCond %{HTTP:X-Forwarded-For} . [OR]
RewriteCond %{HTTP:CF-Connecting-IP} . RewriteCond %{HTTP:CF-Connecting-IP} .
RewriteRule ^.*$ - [F,L] RewriteRule ^ - [L,F]
# ChatGPT has DDOS'd sites before. Short-circuit any ChatGPT requests to HTTP 429.
RewriteCond %{HTTP_USER_AGENT} ChatGPT-User
RewriteRule ^ - [L,R=429]
# In RewriteCond, RewriteRule gets evaluated BEFORE RewriteCond, so $1 refers to the first # In RewriteCond, RewriteRule gets evaluated BEFORE RewriteCond, so $1 refers to the first
# match in RewriteRule # match in RewriteRule