Sep 16 2022
Aug 31 2022
Resource
BlogTopic
Edge DeliveryDate
Mar 03, 2020EdgeRules is a powerful tool that lets you customize the behavior of StackPath’s CDN at different phases of the CDN request. You can add basic and complex functions that affect the site’s caching behavior, configure headers, perform redirects, and much more.
EdgeRules was one of our earliest releases alongside our CDN and we recently spent some time adding even more features to it. With these new features, you can further optimize how you handle requests at the network edge.
Below, we’ll summarize these new features and offer some examples for how you can use them.
Now you can use the “Add Response Header” option, the “Add Header to CDN” option, and the “Add Header to Origin” option under the same rule.
Now you can use all the data we have to enrich the data we send to your origin, as well as add more information to your log or WAF events. You can also use variables with one of the “Add Headers” actions. For example, you can add a new header with %client.request.host%
as the value (i.e. the hostname in the Host header of the request) that is sent to your origin.
We made it easier than ever to use EdgeRules by upgrading the help section with more examples and use cases. The new help section is available from inside your control panel or the EdgeRules support page.
We redesigned the EdgeRules engine and made it easier for you to create and manage EdgeRules!
Using the EdgeRules “Add Header to CDN” action, you can add headers that are added to WAF security events. SImply type your desired header name with one of the available variables as an action.
Here are a few examples of data you can use:
%client.geoip.countryCode%
—Two-character ISO-3166-1 country code of request origin%client.geoip.countryName%
—Country name of request origin%client.geoip.latitude%
—Lattitude of request origin%client.geoip.longitude%
—Longitude of request originThe following rule detects when “iPhone” or “Android” exists in the headers (usually the User-Agent header) and redirects users to https://m.example.com
when they exist.
This rule adds the client’s city code to the request so you can gather more information about users accessing CDN content.
To start creating rules with the new EdgeRules features, go to the Sites section in the StackPath control panel and select EdgeRules from the dropdown menu. You can also create and edit rules with the EdgeRules API.
If you’ve never used EdgeRules before and want to leverage these new features, check out the Getting Started guide for EdgeRules and contact our support team with any questions!