m4nifest0-tech

Search the site

Cybersecurity

Protecting self-hosted services with Anubis behind Nginx Proxy Manager

Anubis in an LXC container on Proxmox, behind Nginx Proxy Manager: configuration, internal HTTPS and the three errors met during the integration.
Published on 8 min readLevel: Intermediate

Anubis is a proof-of-work anti-bot reverse proxy, designed to stop aggressive scraping by AI crawlers and automated bots before they reach self-hosted services. It sits as an intermediate layer between the client and the backend: every visitor has to solve a small computational challenge before getting a verification cookie and reaching the real content.

This guide documents a practical deployment on a Proxmox cluster, integrated with Nginx Proxy Manager (NPM) as the existing TLS termination and reverse proxy, including the pitfalls met during configuration and how they were solved.

Architecture

The architecture has three distinct components:

  • Anubis runs in a dedicated Proxmox LXC container, listening on an internal HTTP port (for example :8923) and with a separate endpoint for Prometheus metrics (:9090).
  • NPM, already in place as reverse proxy and TLS terminator for all services, is configured to route traffic to Anubis instead of straight to the backend.
  • The backend, the real service to protect, is the address Anubis's TARGET points to.

The traffic flow is therefore:

client → NPM (TLS termination) → Anubis (proof-of-work and cookie check) → application backend

Each service to protect needs its own Anubis instance, with a dedicated bind port and TARGET, while NPM stays the single entry point for all domains.

Installation

Anubis is installed as an LXC container with the community-scripts.org script (opens in a new tab), run directly from the Proxmox node shell:

On the Proxmox node
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/DevScripts/main/ct/anubis.sh)"

The script creates the container, installs the Anubis binary and sets up a template-based systemd unit, anubis@<name>.service, which lets you run several independent instances of the same binary with different configurations. The base configuration is written to /etc/anubis/main.env, and the default instance is started with:

In the Anubis container
systemctl enable --now anubis@main

Configuration

The /etc/anubis/main.env file defines the instance's behavior through environment variables. The most relevant ones:

variablewhat it does
BIND, BIND_NETWORKlistening port and protocol (e.g. BIND=:8923)
METRICS_BINDseparate endpoint for Prometheus metrics
DIFFICULTYcomplexity of the proof-of-work challenge
SERVE_ROBOTS_TXTwhether to serve a custom robots.txt
POLICY_FNAMEpath of the YAML file with the bot-detection policies
ED25519_PRIVATE_KEY_HEXkey used to sign the verification cookies
TARGETaddress of the real backend to protect

Two variables deserve particular attention, because they govern the consistency between Anubis and the upstream reverse proxy:

  • USE_REMOTE_ADDRESS: set it to false when Anubis receives traffic from NPM (which forwards the X-Real-IP/X-Forwarded-For headers), and to true only when testing Anubis with direct access, with no proxy in front.
  • COOKIE_SECURE: set it to true as soon as you work over HTTPS, for the reason explained further down.

Finally, if Anubis reaches the protected backend over HTTPS with a certificate that does not cover the IP address used for the connection, TARGET_INSECURE_SKIP_VERIFY=true is needed.

Warning

TARGET_INSECURE_SKIP_VERIFY=true turns off verification of the backend certificate: it is acceptable only when the traffic between Anubis and the backend stays inside your own network.

Integration with Nginx Proxy Manager

In NPM, create a Proxy Host for each domain to protect, with Forward Hostname/IP and Forward Port pointing to the address and port of the matching Anubis instance, no longer straight to the backend.

It is essential to add, in the Proxy Host's Custom Nginx Configuration tab (gear icon), the block that correctly forwards the client headers:

Proxy Host → Custom Nginx Configuration
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;

Without this block Anubis does not receive the headers it expects and, with USE_REMOTE_ADDRESS=false, rejects the request with a misconfiguration error.

The TLS certificate is still managed by NPM as for any other Proxy Host: Let's Encrypt for public domains, or a custom certificate for internal domains, as described in the next section.

HTTPS for internal use

To protect services meant exclusively for internal use, on a .lan domain resolved by your own network, end-to-end HTTPS is still required (for the same reason as the cookie problem). NPM has no built-in generator for self-signed certificates — the certificates menu only offers Let's Encrypt or importing a custom certificate — so the certificate has to be generated manually with openssl:

openssl req -x509 -nodes -newkey rsa:2048 \
  -keyout nomeservizio.lan.key -out nomeservizio.lan.crt -days 825 \
  -subj "/CN=nomeservizio.lan" \
  -addext "subjectAltName=DNS:nomeservizio.lan"

The generated certificate and key are imported into NPM as a "Custom Certificate" and assigned to the relevant Proxy Host.

To resolve the .lan domain, add a DNS rewrite on your internal resolver (for example AdGuard Home), pointing the domain to NPM's IP address.

Important

If there are several resolver instances on the network, the rewrite rule must be added on all of them: otherwise the domain resolves only some of the time, depending on which instance answers.

On first access the browser shows an untrusted-certificate warning, since the certificate is self-signed: this is expected for purely internal use, and has to be accepted manually ("Advanced → Proceed").

Common problems and solutions

Three recurring problems came up during the integration; they are worth knowing in advance.

X-Real-IP header is not set

Symptom. Anubis answers with a misconfiguration error:

[misconfiguration] X-Real-IP header is not set

Cause. USE_REMOTE_ADDRESS=false is set, but Anubis is not actually receiving the X-Real-IP/X-Forwarded-For headers from an upstream reverse proxy: typically because Anubis is being tested with direct access, or because the custom header block in NPM has not been applied.

Fix. Make sure traffic always goes through NPM, with the headers correctly forwarded.

"Your browser is configured to disable cookies"

This is the most insidious of the three.

Symptom. The error saying that your browser is configured to disable cookies keeps appearing, even when cookies are enabled in the browser.

Cause. Anubis sets the verification cookie with the Partitioned attribute (part of the CHIPS standard), and modern browsers silently reject any Partitioned cookie that does not also carry the Secure attribute, regardless of SameSite. Over plain HTTP the cookie is therefore always discarded, whatever the rest of the configuration.

Fix. The only solution is to serve Anubis exclusively over HTTPS (through NPM), with COOKIE_SECURE=true set in main.env.

When in doubt, a direct request settles the matter: it shows the full Set-Cookie header, including the attributes actually applied.

curl -sD - -o /dev/null -A "Mozilla/5.0" -H "Accept: text/html" http://<ip-anubis>:<port>/

cannot validate certificate … doesn't contain any IP SANs

Symptom. It appears when Anubis reaches the protected backend over HTTPS using its IP address:

x509: cannot validate certificate for <ip> because it doesn't contain any IP SANs

Cause. Unlike NPM, the Go HTTP reverse proxy used by Anubis validates the backend's TLS certificate by default, and fails if that certificate does not include the IP as a Subject Alternative Name.

Fix. The dedicated option is TARGET_INSECURE_SKIP_VERIFY=true in main.env, to be used when the traffic stays inside your own network and the backend is already implicitly trusted.

Extending the protection to other services

To protect other services exposed to the Internet, replicate the same Anubis instance under a different name, taking advantage of the systemd template. Copy the existing configuration:

In the Anubis container
cp /etc/anubis/main.env /etc/anubis/nomeservizio.env

and change just three values:

  • BIND, to a free port different from those already in use;
  • METRICS_BIND, likewise;
  • TARGET, to the address of the new backend to protect.

The other variables (COOKIE_SECURE, USE_REMOTE_ADDRESS, POLICY_FNAME) can stay unchanged if you want the same bot-detection policy for all services. The instance is enabled with:

In the Anubis container
systemctl enable --now anubis@nomeservizio

The matching Proxy Host in NPM is then updated to point to the new port, with the same custom header block described earlier.

Internal-only services

For services that cannot be reached from the Internet a different consideration applies. Anubis exists to stop scrapers and bots coming from outside through the proof-of-work challenge: if a service is never exposed publicly, that scenario simply does not arise, because the traffic it receives already comes only from your own network or from trusted devices.

Adding Anubis in this case remains technically possible — with the same procedure, pointing a .lan domain to a new instance — but it only adds one more step of friction (waiting for the proof-of-work challenge) on every access, with no real security benefit beyond what a perimeter firewall or the threat-detection tools on the network already provide.

It makes sense to consider it as an additional defensive layer only if you want to protect an internal service from automated tools launched by a possibly compromised LAN host as well, not as a standard measure for every locally accessed service.

Related articles