Firewall quickstart
Create a firewall, add a rule that denies requests to one path, bind the firewall to a workload, and confirm the path answers 403.
This guide instructs you through denying your first request with a firewall.
- Create a firewall for the application you already serve.
- Add a rule that denies every request to one path.
- Bind the firewall to the workload that serves your application.
- Send a request to that path and read the
403it returns.
Four objects turn a request into a decision, and each one links to the next:
- The firewall holds the rules. It is active from the moment you create it.
- The rule on that firewall pairs a criterion with a behavior. The criterion selects requests, and the behavior decides what happens to them. In this guide, the criterion selects every path that starts with
/deny-test, and the behavior denies the request. - The deployment of the workload that serves your application names that firewall, beside the application.
- The request to the workload’s domain meets the rule, and a denied request never reaches your application.
A firewall inspects nothing on its own. Until a workload’s deployment names it, no request reaches its rules.
Web Application Firewall (WAF), Network Shield, and Bot Manager are Products enabled on a firewall. This guide needs none of them, because Deny is built into every firewall. Each Product’s quickstart starts from a firewall bound to a workload, which is what this guide leaves you with.
Select the interface you use. The prerequisites and every stage on this page follow that choice.
Prerequisites
- An Azion account. To create one, refer to Create an account.
- A workload that serves an application on its workload domain. For more information, refer to Workloads.
- Access to Azion Console. To sign in, refer to Access Azion Console.
Create the firewall
A new firewall holds no rules, and it starts active. The Deny rule this guide adds needs no Product turned on, so the default settings stay.
To create the firewall with the Azion CLI:
The command prints the ID of the new firewall:
The firewall is active, with Functions and Network Shield turned on and WAF turned off. Record the ID. The rule and the binding to your workload pass it as --firewall-id.
Add a rule that denies one path
A Rules Engine for Firewall rule pairs criteria with behaviors. The rule in this stage carries one criterion, a request URI that starts with /deny-test, and one behavior, Deny. Deny refuses the request with 403 Forbidden, and it needs no Product turned on.
The criterion matches every path that begins with /deny-test, so /deny-test/page matches too. For more information, refer to Deny (403 Forbidden).
azion create firewall-rule reads the whole rule from a JSON file. criteria is a list of groups, and the first criterion of a group carries the conditional if. Save this rule as rule.json:
Create the rule. Replace <firewall-id> with the ID of your firewall:
The command prints the ID of the new rule:
The rule is active on the firewall.
Bind the firewall to your workload
A firewall has no domain of its own. The workload carries the domain. Its deployment holds exactly three settings: the application, the firewall, and the custom page. Name the application the workload serves today, and its custom page if it uses one, beside your firewall. Until the deployment names your firewall, the Deny rule matches no request.
To bind the firewall with the Azion CLI, create a deployment that names your firewall and the application the workload serves today. Replace the three IDs:
The command prints the ID of the new deployment:
--current true makes it the current deployment of the workload, which names your application and your firewall. If the workload uses a custom page, add --custom-page <custom-page-id> to the command.
Confirm that the path answers 403
The check is the same whichever interface built the firewall. Your workload answers on its workload domain, of the form <id>.map.azionedge.net, written in this stage as <your-workload-domain>.
A workload newly bound to a firewall can take several minutes to enforce its first rule, and no duration is guaranteed. While the binding spreads, answers to the same request alternate between the earlier response and the new one. Until then, the path still reaches your application. Send the request again until it answers 403. For more information, refer to Propagation.
Send a request to the denied path:
The firewall refuses it with 403:
The response also carries a long content-security-policy header, omitted from this excerpt. The body is Azion’s default error page, headed Forbidden, and it lists your IP address and the request ID. No header names the firewall or the rule that refused the request.
Requests to every other path do not match the rule, and your application answers them as before. Your firewall denies every request whose path starts with /deny-test.