Block AI bots crawlers on Nginx(github.com) |
Block AI bots crawlers on Nginx(github.com) |
if ($server_protocol != HTTP/2.0) { return 444; }
Here's another one that will block most non-browsers (except for headless chrome of course) if ($http_sec_fetch_mode !~ (cors|no-cors|navigate) ) { return 444; }
These should be tested extensively on a non revenue impacting site.Another bot-blocking method is to drop any TCP SYN packets with an MSS outside of a sensible range. Here is an example using netfilter on IPv4 in the "raw" table (to keep them out of the CPU impacting state table):
-A PREROUTING -i eth0 -p tcp -m tcp -d {your_wan_ip} --syn -m tcpmss ! --mss 1220:1460 -j DROP
listen[::]443 ssl http2;
thank you.
nginx -v server {
listen 443 ssl backlog=1536 so_keepalive=58s:58s:5 deferred reuseport;
http2 on;
# [snip...]
This is on nginx/1.26.2. Older versions looked a little different. http2 on; # instead of being in the listen line.
[1] - https://nginx.org/news.html