From 1ec36a9289d9841bf5188c9c5504c3968cbe108e Mon Sep 17 00:00:00 2001 From: z0x Date: Thu, 8 May 2025 23:04:58 -0400 Subject: [PATCH] refactor: fork reverted from vale981/anubis back to TecharoHQ/anubis. removed unused files. bumped go dependencies. removed Caddyfile, LICENSE, and index.html --- Caddyfile | 20 -------------------- LICENSE | 15 --------------- README.md | 31 ++++++++++++++----------------- caddy_anubis.go | 6 +++--- go.mod | 5 ++--- go.sum | 10 ++-------- web/index.html | 9 --------- 7 files changed, 21 insertions(+), 75 deletions(-) delete mode 100644 Caddyfile delete mode 100644 LICENSE delete mode 100644 web/index.html diff --git a/Caddyfile b/Caddyfile deleted file mode 100644 index a7a9021..0000000 --- a/Caddyfile +++ /dev/null @@ -1,20 +0,0 @@ - -{ - #order anubis after encode - #order redir after anubis -} - -:18888 { - request_header +X-Real-IP {remote_host} - request_header +X-Forwarded-For {remote_host} - - anubis - - handle / { - try_files {path} /index.html - file_server { - root web/ - browse - } - } -} diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 063a384..0000000 --- a/LICENSE +++ /dev/null @@ -1,15 +0,0 @@ -ISC License - -Copyright (c) 2025 Yulian Kuncheff - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md index 5680193..ff9a322 100644 --- a/README.md +++ b/README.md @@ -2,35 +2,32 @@ caddy-anubis is a plugin that loads anubis for requests in order to slow down AI and Scraper traffic from destroying infrastucture. -I consider this current implementation more of a Proof-of-Concept. I am not sure how stable or well it works. This is my first Caddy plugin. I do not currently recommend it for production usage. - -If you have experience with Caddy plugins, or see obvious issues in my code, feel free to open PRs or reach out to me. +I do not currently recommend it for production usage as the current implementation is more of a Proof-of-Concept then anything and due to it being pinned to anubis v1.15.2 as the main.mjs was no longer served on later versions ## Known Issues -- One major issue is the very first request after a Caddy start or restart, takes like 5 seconds till anubis kicks in. All subsequent requests, even after clearing cookies, are near instant. +- The very first request after a Caddy start or restart takes about 5 seconds before anubis kicks in. All subsequent requests, even after clearing cookies work perfectly and are near instant. -## Current usage +## Usage -Just add an `anubis` to your caddyfile in the block you want the protection. currently I have not seen it work properly inside a `route` or `handler` block. But it works outside of those. +AFIK doesn't work inside a `route` or `handler` block. -There is an optional `target` field you can set if you want to force the redirect elsewhere. It does a 302 redirect. - -Example (also check the caddyfile in this repo, it is used for testing): +Example: ```caddy - -:80 { +#order anubis after encode +#order redir after anubis +localhost { + request_header +X-Real-IP {remote_host} + request_header +X-Forwarded-For {remote_host} anubis - # or - - anubis { - target https://qwant.com - } + reverse_proxy 127.0.0.1:3000 } ``` ## Credits -- [anubis](github.com/TecharoHQ/anubis) - the project that started all of this. +- [TecharoHQ/anubis](https://github.com/TecharoHQ/anubis) +- [daegalus/caddy-anubis](https://github.com/daegalus/caddy-anubis) +- [vale981/caddy-anubis](https://github.com/vale981/caddy-anubis) diff --git a/caddy_anubis.go b/caddy_anubis.go index cfd94a6..a067d0d 100644 --- a/caddy_anubis.go +++ b/caddy_anubis.go @@ -4,9 +4,9 @@ import ( "log/slog" "net/http" - "github.com/vale981/anubis" - libanubis "github.com/vale981/anubis/lib" - "github.com/vale981/anubis/lib/policy" + "github.com/TecharoHQ/anubis" + libanubis "github.com/TecharoHQ/anubis/lib" + "github.com/TecharoHQ/anubis/lib/policy" "github.com/caddyserver/caddy/v2" "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile" "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" diff --git a/go.mod b/go.mod index 78f2e25..f05d572 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ -module github.com/vale981/caddy-anubis +module github.com/TecharoHQ/caddy-anubis go 1.24.2 require ( + github.com/TecharoHQ/anubis v1.15.2 github.com/caddyserver/caddy/v2 v2.10.0 - github.com/vale981/anubis v0.0.0-20250423170453-07b0c024fa1b go.uber.org/zap v1.27.0 ) @@ -26,7 +26,6 @@ require ( github.com/Masterminds/semver/v3 v3.3.1 // indirect github.com/Masterminds/sprig/v3 v3.3.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/TecharoHQ/anubis v1.16.0 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/go.sum b/go.sum index 3eafea5..ff1530a 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/TecharoHQ/anubis v1.16.0 h1:/OcjM+aQLOUwTbM9Xc/ARMfKhr36gEON5hWETaFsdpM= -github.com/TecharoHQ/anubis v1.16.0/go.mod h1:3PaeFxgrxzDCPhY1gwuM5A5yEoyndQiXSeq9+Vik2MM= +github.com/TecharoHQ/anubis v1.15.2 h1:GO36EKld46wL7GAoO0JZoerg/Tj0Ky6u+ob99sqRzag= +github.com/TecharoHQ/anubis v1.15.2/go.mod h1:69DVTFehEtvV/+V42ThkzG78Mtot1bJKvi4I6u6FJUI= github.com/a-h/templ v0.3.857 h1:6EqcJuGZW4OL+2iZ3MD+NnIcG7nGkaQeF2Zq5kf9ZGg= github.com/a-h/templ v0.3.857/go.mod h1:qhrhAkRFubE7khxLZHsBFHfX+gWwVNKbzKeF9GlPV4M= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= @@ -117,7 +117,6 @@ github.com/coreos/go-oidc/v3 v3.14.1 h1:9ePWwfdwC4QKRlCXsJGou56adA/owXczOzwKdOum github.com/coreos/go-oidc/v3 v3.14.1/go.mod h1:HaZ3szPaZ0e4r6ebqvsLWlk2Tn+aejfmrfah6hnSYEU= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= @@ -161,7 +160,6 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -419,10 +417,6 @@ github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cb github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v1.22.16 h1:MH0k6uJxdwdeWQTwhSO42Pwr4YLrNLwBtg1MRgTqPdQ= github.com/urfave/cli v1.22.16/go.mod h1:EeJR6BKodywf4zciqrdw6hpCPk68JO9z5LazXZMn5Po= -github.com/vale981/anubis v0.0.0-20250423163257-50ea88514c78 h1:0qrk1hT5OKSc4UWxyml9B70p/qmHUQa/Bq6FrMY34QE= -github.com/vale981/anubis v0.0.0-20250423163257-50ea88514c78/go.mod h1:k+YSG00ruI4PCDA5cQyUvuf0Ro7Wd05bcGwmxzH91/o= -github.com/vale981/anubis v0.0.0-20250423170453-07b0c024fa1b h1:pWPAg/T4oyJIF7B82yCDl8ZsS07TqaeftZx5wXBrxSg= -github.com/vale981/anubis v0.0.0-20250423170453-07b0c024fa1b/go.mod h1:k+YSG00ruI4PCDA5cQyUvuf0Ro7Wd05bcGwmxzH91/o= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= diff --git a/web/index.html b/web/index.html deleted file mode 100644 index d55ea65..0000000 --- a/web/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - Home - - -

Welcome to the Home Page

-

Click here to go to the About Page

- - \ No newline at end of file