From fe8a072b89a6ba2058a6ce0995400bb78526e05d Mon Sep 17 00:00:00 2001 From: Fuhu Xia Date: Mon, 2 Oct 2023 13:06:40 -0400 Subject: [PATCH] exclude bots from tracking --- proxy/nginx-botbegone.conf | 21 +++++++++++++++++++++ proxy/nginx.conf | 1 + 2 files changed, 22 insertions(+) create mode 100644 proxy/nginx-botbegone.conf diff --git a/proxy/nginx-botbegone.conf b/proxy/nginx-botbegone.conf new file mode 100644 index 00000000..21996f5a --- /dev/null +++ b/proxy/nginx-botbegone.conf @@ -0,0 +1,21 @@ +# prevent top 6 bots from entering data into /_tracking +## Googlebot/ +## Y!J +## Yeti +## Bytespider +## Applebot +## HeadlessChrome + +set $botstracking 0; + +if ($uri = "/_tracking") { + set $botstracking 1; +} + +if ($http_user_agent ~ 'Googlebot/|Y!J|Yeti|Bytespider|Applebot|HeadlessChrome') { + set $botstracking "${botstracking}1"; +} + +if ($botstracking = 11) { + return 200; +} diff --git a/proxy/nginx.conf b/proxy/nginx.conf index 46991cd3..ae399678 100644 --- a/proxy/nginx.conf +++ b/proxy/nginx.conf @@ -38,6 +38,7 @@ http { server_name {{env "EXTERNAL_ROUTE"}} {{env "PUBLIC_ROUTE"}}; include nginx-cloudfront.conf; + include nginx-botbegone.conf; include nginx-common.conf; }