Middleware
Middleware
Put DNA in front of every request on the server or platform your site runs on, and keep your DNS host.
Not sure which install fits? Compare it with nameservers.
Vercel
One middleware.ts for any framework on Vercel.
Cloudflare
One line in your Worker, or a deploy button for a site hosted anywhere.
nginx
A check on each location that serves your site, on any nginx.
Caddy
One forward_auth block in your Caddyfile.
IP and country conditions
A rule's IP address and Country conditions work only when your middleware sends DNA that value. Check your row before you add either one. On our nameservers, a proxied record sends both; a DNS-only one goes around DNA, so its own middleware decides.
| Middleware | IP address | Country |
|---|---|---|
| Vercel | Yes | Yes |
| Cloudflare Worker, or deploy button | Yes | Yes |
| Cloudflare Snippet | Yes | No |
| nginx | Yes, the address nginx sees | No |
| Caddy | Yes, the address Caddy sees | No |
- Where your middleware doesn't send a value, a condition on it never matches, and an "is not" condition matches every request.
- To narrow a rule by country, use Vercel or the Cloudflare Worker.
- Behind a load balancer, nginx sees the balancer's address. Turn on nginx's
real IP module
with
set_real_ip_fromset to your balancer's addresses only: a visitor can write any address intoX-Forwarded-For, so a header you don't trust would let them pick their own IP.