How to Upload Rules to Cloudlet Akamai

Some Cloudlets support the apply of regular expressions in lucifer rules. The regular expression can be up to 256 characters.

Cloudlets use the RE2 regular expressions library, which uses the finite-state machine (FSM) computational model and uses a C++ interface. Check out Syntax documentation on GitHub, or go to a similar site, for information nigh RE2's syntax.

These Cloudlets support regular expressions in match rules:

Cloudlet

Support provided

Audience Sectionalization

  • Use regular expressions to match on the fully-qualified URL of an incoming request.
  • Use regular expression capture groups to class the forward path and query string.
  • Border Redirector

  • Utilize regular expressions to match on the fully-qualified URL of an incoming request.
  • Use regular expression capture groups to grade the redirect URL.
  • Forward Rewrite

  • Use regular expressions to friction match on the fully-qualified URL of an incoming asking.
  • Utilize regular expression capture groups to form the forward path and query string.
  • Input Validation

  • Employ regular expressions to friction match on the fully-qualified URL of an incoming request.
  • Use regular expressions to match on form field names or values in the incoming request.
  • The following diagram shows the characters y'all can utilise for each function of the URL when creating a regular expression for Cloudlets.

    regexp

    If your regular expression includes whatever characters that have a special use in regular expressions (like ".", "+", or "?"), you must use a backslash ("\") to escape each special character.

    Capture groups allow you to capture incoming information from the source URL, while substitution patterns allow you to refer to those capture groups in the modified URL. Substitution patterns use the dorsum slash character ("\") followed past a number to refer to the capture groups. For example, \1 is the first capture grouping, \2 is the second, etc.

    📘

    Input Validation does not utilize capture groups.

    The post-obit diagram shows how you can set upwardly numbered capture groups on parts of an entering URL for Edge Redirector.

    capture_groups

    Named capture groups

    The URL Regular Expression match for Cloudlets supports a maximum of nine numbered substitutions using capture groups.

    When using named capture groups, employ the following syntax earlier the regular expression (regex): (?P regex). As the RE2 library supports named capture groups as numbered substitutions, use \n for the exchange string.

    Remember that the maximum size of a regular expression is 256 characters.

    Here's how a regex for Edge Redirector would await using both capture grouping methods:

    Capture Group Type

    Syntax

    Numbered Capture Group

  • **Regex**: (http|https)://www.(vanity|vanity1).com/(.*)
  • **Redirect URL:** \i://www.company.com/\ii/\3
  • Named Capture Grouping

  • **Regex:** (?P http|https)://world wide web.(?P vanity|vanity1).com/(?P .*)
  • **Redirect URL:** \1://www.visitor.com/\ii/\3
  • Y'all can use the Regex Tester to verify that the regular expression and exchange patterns you enter volition produce the desired results.

    Yous can admission the Regex Tester when you select the URL Regular Expression match blazon on the Create a Rule screen.

    How to

    1. Go to > CDN > Edge logic Cloudlets.

    2. On the Cloudlet Policies screen, select a policy.

    3. On the Policy Details screen, either create a new version or click the version you want to view.

    4. On the dominion manager page, click Add Rule.

    5. On the Create a Rule screen,

      1. select URL Regular Expression.

      2. click Show Regex Tester.

    6. Complete the post-obit fields for the Regex Tester:

    Regex Tester Fields

    Activity

    Regular Expression

    Enter a regular expression of up to 256 characters to friction match on the inbound URL, minus the port. For example: (http|https)://www.(vanity|vanity1).com/(.*)

    Redirect URL (Edge Redirector)

    If applicable, enter the substitution pattern to create the modified URL. For example: \1://www.company.com/\two/\3

    Note that the pattern uses backslash, "\", and not dollar sign "$".

    Path and Query Cord (Forward Rewrite)

    Enter the substitution pattern to create the path and query string that will form the modified URL. To define the substitution pattern, employ the capture groups in the Regular Expression field. For example: /\1/\ii

    Note that the blueprint uses backslash, "\", and not dollar sign "$".

    Test URL

    Enter a URL to test whether the regular expression and any capture groups entered produce the desired URL.

    📘

    In the And so section of the rule screen, the Redirect URL or Path and Query String field is disabled, but displays values entered in the aforementioned field for the Regex Tester.

    1. Click Validate.
    2. In the results department, verify that the values entered produced the desired URLs.

    Before using the URL Regular Expression match with Cloudlets, consider the following:

    • There is a maximum processing price per policy. Regular expressions take a very high processing cost, often 100 times more expensive than other lucifer criteria. The bodily number of rules processed per policy depends on the complexity of the regular expressions divers. You can exceed the maximum cost for the policy by equally few as fifty to 100 regular expressions.

    • Merely use regular expressions and capture groups if you demand to excerpt a value and use information technology in either a redirect or a forward path. They add significant toll.

    • When using regular expressions, you can reduce the price by constructing your rule to kickoff match based on path or query cord before matching on the regex. The path and query cord matches both permit wildcards.

    • Don't include the incoming protocol in the regex if the redirect path uses the same protocol. In the regex implementation for Cloudlets, the incoming protocol is included by default.

      For instance, if your regex is ^https?://www.test.com/(.*)/ and \1://www.test1.com/\two is the redirect, you tin can utilise www.exam.com/(.*) as the regex and world wide web.test1.com/\1 equally the redirect instead.

    • As processing errors occur during runtime, the merely way currently to determine whether your policy will exceed the maximum processing cost is through thorough testing. If you hit the maximum during testing, try making your regular expressions more efficient, and follow the all-time practices listed below.

    If you lot need to employ a regex match, consider following these best practices:

    • Don't use regular expressions to specify alternatives. For example, if you desire to match on a limited number of paths, like http://www.example.com/(choice1|choice2|choice3)/, create separate rules for each selection instead:

      • http://www.instance.com/choice1/
      • http://world wide web.case.com/choice2/
      • http://www.example.com/choice3/

      In this case, while using the regular expression reduces the number of rules you lot have, it increases the toll significantly. Remember, the cost to evaluate one regular expression is often 100 times more than expensive than the respective set of rules rewritten without regular expressions.

    • Review the listing of rules for the entire policy version and sort based on the post-obit order of precedence:

      • Protocol (HTTP/HTTPS)
      • Hostname
      • Path
      • Query String
    • If you take to utilise regular expressions in a rule, include a combination of hostname, path, and query string matches whenever possible to reduce the cost. For example:

    Case

    Match Structure

    Commutation Pattern for Redirect

    You lot want to extract the product ID from a query string parameter, and redirect using the ID equally a path parameter.

    1. Query String match: prod_id=*
    2. Regex lucifer: ^https?://host1.example.com/path1(?:.*)[?&]prod_id(?:=([^&]*))?

    https://host2.example.com/products/\1

    You desire to capture everything after /path1/* on host1.example.com and re-road to /path2/ on host2.case.com.

    1. Path match: /path1/*
    2. Regex match: ^https?://host1.example.com/path1/?(.*)?

    https://host2.example.com/path2/\1


    mitchelldenjudd42.blogspot.com

    Source: https://techdocs.akamai.com/cloudlets/docs/regex-cloudlets-rules

    0 Response to "How to Upload Rules to Cloudlet Akamai"

    Post a Comment

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel