Control with EdgeRules

Our EdgeRules feature allows you to control how your content is delivered from the Pull Zone by customizing asset delivery.

Edge rule

Recipes

Designed to help you get started with EdgeRules, our recipes provide you with predefined rules for the most common cases. Visit EdgeRules Flavours to get started.

Multi_CDN

Origin Server Optimization

Manipulate headers, reduce the number of calls made to your origin server, create custom redirects and more.

Token Security

Go Mobile

Create a better user experience by providing separate caches for mobile and non-mobile devices.

Technical Details

Creating a Custom EdgeRule

You can create 100% custom EdgeRules or use and modify the other recipes shown here. You can use the following options which are laid out in a simple user friendly format:

  • Match type: e.g. Exact, Literal (and many more)
  • Match location: The URI
  • Match location case sensitive: yes or no
  • Directive: e.g. Status code, Ignore query string, Deny (many more plus custom directives)
  • Directive value
  • Optional conditional: $variable and Relational operator (and value)
  • Multiple sets of directives and conditionals (points 4-6)
  • Rule priority
  • Purge cache: yes or no
  • Realtime activation or save and finish later
Hide X-Powered-By Header

Some applications add this header to all HTTP responses and it often contains the application name and version which can be a security risk. This recipe allows you to hide it.

Match Type Default
Features HIDE HEADER X-Powered-By
Hide S3 Headers

Amazon S3 by default adds lots of useless to the user HTTP headers. You can remove them to minimize the transferred data.

Match Type Default
Features HIDE HEADER x-amz-id-2
HIDE HEADER x-amz-meta-s3fox-filesize
HIDE HEADER x-amz-meta-s3fox-modifiedtime
HIDE HEADER x-amz-request-id
Add X-XSS-Protection Header

X-XSS-Protection is a HTTP header understood by Internet Explorer 8 (and newer versions). This header lets domains toggle on and off the “XSS Filter” of IE8, which prevents some categories of XSS attacks.

Match Type Default
Features ADD HEADER X-XSS-Protection "1; mode=block"
Block by Country

This will allow the customer to block certain Countries. In this example we will return a 403 when a visitor is coming from China (CN).

Match Type Default
Features if ( $geoip_city_country_code = CN ) {
STATUS CODE 403
}
Redirect All Bots

To improve your SEO scores you can redirect all bots that hit the CDN to your origin.

Match Type Exact
Features if ( $http_user_agent ~* ~(crawl|Googlebot|Slurp|spider| bingbot|tracker|click|parser|spider) ) {
REWRITE RULE ^ https://static.origin.com$request_uri permanent
}
Add X-Pull Request Header

Specify a X-Pull request header key to have the possibility to restrict access to your origin server (X-Pull: [key])

Match Type Default
Features if ($http_x_pull ~* "Your_secret_key") {
return 405;}
HLS .m3u8

Caching will be disabled for index file .m3u8

Match Type Regex
Features if (Location \.m3u8 ) {
BYPASS CACHE 1
}
Add X-Robots-Tag

You can use this recipe to disallow bots to index different parts of your website. A flexible alternative to robots.txt file.

Match Type Regex
Location \.(?:pdf|htm?l|png|jpe?g|gif)$
Features ADD HEADER X-Robots-Tag "noindex"
ADD HEADER X-Robots-Tag "googlebot: nofollow"
Add X-Frame-Options Header

This header can be used to indicate whether or not a browser should be allowed to render a page in a <frame> or <iframe>

Match Type Default
Features ADD HEADER X-Frame-Options SAMEORIGIN
ADD HEADER X-Frame-Options DENY
ADD HEADER X-Frame-Options "ALLOW-FROM $uri"
CORS Headers

Cross-Origin resource sharing allows other websites to request content from your domain using JavaScript or CSS. Required for web fonts to work.

Match Type Regex
Location \.(ttf|ttc|otf|eot|woff|font.css|css)$
Features ADD HEADER Access-Control-Allow-Origin "*"
Hide Server Header

This recipe allows you to hide the Server header from all HTTP responses.

Match Type Default
Features HIDE HEADER Server
Force HTTPS Connections

Forces the use of HTTPS connections. All HTTP requests will be redirected to HTTPS.

Match Type Default Location /example.html
Features if ( $scheme = http ) {
REWRITE RULE ^ https://$http_host$request_uri permanent
}
Redirect by Referrer

You can redirect all users that come from a specific website. This rule can be used to ban websites that steal bandwidth or show different content from visitors from other websites.

Match Type Exact
Location /example.html
Features if ( $http_referer ~ https://domain.com ) {
REWRITE RULE ^ https://example.com/banned.html permanent
}
Redirect by Country

This will allow the customer to redirect certain Countries. In this example we will redirect users from the United States and United Kingdom to an English version of the website they are visiting.

Match Type Default
Features if ( $geoip_city_country_code ~* (US|UK) ) {
REWRITE RULE ^ https://english.$http_host$request_uri$1 permanent
}
HLS .ts (Live)

This will allow the ts file .ts to be cached for 60 second

Match Type Regex
Features if ( Location \.ts ) {
IGNORE QUERY STRING 1 TTL OVERRIDE 60s ADD HEADER Cache-Control max-age=60
}
HLS .ts (VOD)

The ts file .ts will be cached for 3600 second

Match Type Regex
Features if (Location \.ts ) {
IGNORE QUERY STRING 1 TTL OVERRIDE 3600s ADD HEADER Cache-Control max-age=3600
}
Add Canonical Header

Allows you to specify the original domain that should be attributed with the SEO score instead of the CDN accelerated one.

Match Type Regex
Location \.(?:pdf|htm?l|png|jpe?g|gif)$
Features ADD HEADER

Click here to explore other features with 5centsCDN

Learn how to use Edge Rules?

visit our knowledgebase here