Reverse proxy (the default): BotStopper sits in the middle of all traffic and then will reverse proxy it to its destination. This is the moral equivalent of a middleware in your favorite web framework.
Subrequest authentication mode: BotStopper listens for requests and if they don't pass muster then they are forwarded to BotStopper for challenge processing. This is the equivalent of BotStopper being a sidecar service.
Note.
Subrequest authentication requires changing the default policy because nginx interprets the default DENY status code 200 as successful authentication and allows the request.
In order to configure this, you need to add the following location blocks to each server pointing to the service you want to protect:
location /.within.website/ { # Assumption: Anubis is running in the same network namespace as # nginx on localhost TCP port 8923 proxy_pass http://127.0.0.1:8923; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass_request_body off; proxy_set_header content-length ""; auth_request off;}location @redirectToAnubis { return 307 /.within.website/?redir=$scheme://$host$request_uri; auth_request off;}
This sets up /.within.website to point to BotStopper. Any requests that BotStopper rejects or throws a challenge to will be sent here. This also sets up a named location @redirectToAnubis that will redirect any requests to BotStopper for advanced processing.
This will check all requests that don't match other locations with BotStopper to ensure the client is genuine.
This will make every request get checked by BotStopper before it hits your backend. If you have other locations that don't need BotStopper to do validation, add the auth_request off directive to their blocks:
Then configure the necessary directives in your site block:
route { # Assumption: Anubis is running in the same network namespace as # caddy on localhost TCP port 8923 reverse_proxy /.within.website/* 127.0.0.1:8923 forward_auth 127.0.0.1:8923 { uri /.within.website/x/cmd/anubis/api/check trusted_proxies private_ranges @unauthorized status 401 handle_response @unauthorized { redir * /.within.website/?redir={uri} 307 } }}
If you want to use this for multiple sites, you can create a snippet and import it in multiple site blocks.