Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Forked from dangovorenefekt/blockmetatwitter.md
Created June 26, 2023 21:23
Show Gist options
  • Save Epictetus/e23763a1cbb464ed76f683d6e5333483 to your computer and use it in GitHub Desktop.
Save Epictetus/e23763a1cbb464ed76f683d6e5333483 to your computer and use it in GitHub Desktop.
Block Meta and Twitter (nginx)
  1. Modify /etc/nginx/nginx.conf file
  2. Modify /etc/nginx/sites-available/site.conf file
  3. Create /etc/nginx/useragent.rule file

Where to find user agent strings?
https://explore.whatismybrowser.com/useragents/explore/software_name/facebook-bot/

Test:

[rubin@reaper ~]$ curl -A "instagram" -I https://plrm.podcastalot.com
HTTP/2 503
server: nginx/1.18.0
date: Mon, 26 Jun 2023 06:07:25 GMT
content-type: text/html
content-length: 197
http {
.....
include /etc/nginx/useragent.rules
}
server {
....
if ($badagent) {
return 503;
}
....
}
map $http_user_agent $badagent {
default 0;
~*twitter 1;
~*tweet 1;
~*facebookexternalhit 1;
~*facebot 1;
~*facebook 1;
~*instagram 1;
~*chatgpt 1;
~*ccbot 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment