From 8a3a05a264cf87edf7163d88b73c67ab62cf955b Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 24 Mar 2025 13:59:13 -0500 Subject: [PATCH] Ban ChatGPT user agents --- config/apache/standardebooks.org.conf | 6 +++++- config/apache/standardebooks.test.conf | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/apache/standardebooks.org.conf b/config/apache/standardebooks.org.conf index 0555af7a..6578d6b1 100644 --- a/config/apache/standardebooks.org.conf +++ b/config/apache/standardebooks.org.conf @@ -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. RewriteCond %{HTTP:X-Forwarded-For} . [OR] 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 # match in RewriteRule diff --git a/config/apache/standardebooks.test.conf b/config/apache/standardebooks.test.conf index 13c1cc89..37153f49 100644 --- a/config/apache/standardebooks.test.conf +++ b/config/apache/standardebooks.test.conf @@ -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. RewriteCond %{HTTP:X-Forwarded-For} . [OR] 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 # match in RewriteRule