Your rules, in a few lines
Allow or deny a request by its address, country, network, path, method, headers, cookies or parameters. See the effect in the log before enforcing it.
Scenario
DENY · deniedOnly your office can open /admin: the address condition does not match, the path condition denies.
Zarex responseDocs
{
"decision_id": "1f0e3dad99908345f7439f8ffabdffc4",
"verdict": "DENY",
"results": [
{
"rule_type": "REQUEST_FILTER",
"verdict": "DENY",
"is_dry_run": false,
"reason": {
"matched": true,
"expression": 1,
"field": "path",
"operator": "STARTS_WITH"
}
}
],
"ruleset_version": "11.3.0+shield-2.0",
"ip": {
"country": "FR",
"asn": "AS64510"
}
}Simple conditions, read in order
Each condition pairs a field, an operator (equals, contains, starts with, in a list, regular expression, length…) and an action. By default, the first true condition decides.
CIDR ranges are accepted for addresses, and the country or network come from the Zarex address database.
Allow list or deny list
Deny what is dangerous, or allow only what you know with default DENY.
Every filter can run in DRY_RUN: the log shows what would have been blocked, without risking turning away real customers.
In your code
Protect an admin area, or deny useless methods.
import { NextResponse } from "next/server";
import { zarexNext, requestFilter } from "@zarex/next";
const guard = zarexNext({
key: process.env.ZAREX_KEY!,
ipSource: "vercel",
rules: [
requestFilter({
mode: "DRY_RUN", // observer d'abord, dans le journal
conditions: [
{ field: "ip", operator: "IN", values: ["203.0.113.0/24"], action: "ALLOW" },
{ field: "path", operator: "STARTS_WITH", value: "/admin", action: "DENY" },
],
}),
],
});
export async function proxy(request: Request) {
return (await guard(request)) ?? guard.finalize(NextResponse.next(), request);
}Ready for production
Up to 32 conditions
Combined with OR or AND.
CIDR ranges
For IP addresses.
Country and network
ip.country and ip.asn.
DRY_RUN
Test without blocking.
Other protections
Start by observing
Turn the rule on in DRY_RUN, watch the log, then switch to LIVE. A question before you start? Write to us.