Block some of the bots on my website

This commit is contained in:
Konstantin Nazarov 2023-08-15 17:07:16 +01:00
parent 7d603f5a81
commit d4b71942d7
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22

View file

@ -37,6 +37,13 @@
services.nginx = { services.nginx = {
enable = true; enable = true;
commonHttpConfig = ''
map $http_user_agent $limit_bots {
default 0;
~*(AhrefsBot|PetalBot|bingbot|gptbot|ZoominfoBot|BLEXBot|Bytespider) 1;
~*(DecompilationBot|Amazonbot|Barkrowler|SeznamBot) 1;
}
'';
virtualHosts = { virtualHosts = {
"knazarov.com" = { "knazarov.com" = {
enableACME = true; enableACME = true;
@ -56,11 +63,25 @@
add_header "Access-Control-Allow-Origin" *; add_header "Access-Control-Allow-Origin" *;
''; '';
}; };
locations."/" = {
extraConfig = ''
if ($limit_bots = 1) {
return 403;
}
'';
};
}; };
"vmatveeva.com" = { "vmatveeva.com" = {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
root = "${pkgs.vmatveevacom}/srv/vmatveeva.com"; root = "${pkgs.vmatveevacom}/srv/vmatveeva.com";
locations."/" = {
extraConfig = ''
if ($limit_bots = 1) {
return 403;
}
'';
};
}; };
"matrix.knazarov.com" = { "matrix.knazarov.com" = {
enableACME = true; enableACME = true;