Using a TrafficScript Rule
TrafficScript rules are stored in the Rules catalog. You can use the Rules catalog to create rules, upload them from an external source, modify or duplicate them, and delete unused rules as required.
You can configure a Virtual Server to execute one or more rules from the catalog each time it receives a new request or response, or at completion of a transaction. This way, several different Virtual Servers can use the same rule, and modifications to the rule take effect on all Virtual Servers.
To use TrafficScript rules, first create a new rule or upload a previously created rule using the Rules catalog. Then configure your Virtual Server to reference and use this rule.
To Create a Rule in the Catalog
1.Click Configure > Catalogs > Rules Catalog.
2.In the “Create New Rule” section, type a name for your rule.
3.Click Use TrafficScript Language.
4.To create the rule, click Create Rule.
5.On the TrafficScript editing page, type your rule content into the Rule text box. For longer rules, you might want to consider writing the rule in a separate text editor before pasting it in. To view the online function reference, click TrafficScript Help. To syntax check your rule, click Check Syntax.
6.Optionally add a free text description of the rule into the Notes text box.
7.To save your changes, click Update.
Some TrafficScript functions are protocol specific (such as 'http.getHeader()') and can only be used when handling associated connections. Some functions are only appropriate in a request rule or a response rule. For example, a function that modifies a parameter of a response has no effect if used in a request rule (as the response has not yet been received). For more details, refer to the documentation for each function in this guide, or in the Online Help.
To Upload a Rule to the Catalog
Your rules should be in plain text, and the Traffic Manager uses the full filename (including extension) as the rule name.The Traffic Manager performs a syntax check on the uploaded rule file. Warnings and errors are displayed on the Rule catalog page, the Diagnose page, and in the Event Log.
1.Click Catalogs > Rules Catalog.
2.In the "Upload an existing rule" section, click Choose file to select a rule file from your local filesystem.
3.Choose whether to overwrite existing rules that have the same name as your filename.
4.Click Upload Rule.
To Configure a Virtual Server to Use a Rule
1.Click Configure > Virtual Servers and edit your selected Virtual Server.
2.To view and modify the request, response, and transaction completion rules associated with this Virtual Server, click Rules.
You can choose new rules to add to each rule type from the drop-down selection at the bottom of each list.
3.Rules are executed in a specified order. If the first rule does not make a final decision about a request or response, the second rule is tested, and so on. To reorder the list, use the mouse pointer to drag the rule bars up and down as desired.
4.To enable or disable individual rules in the list, use the controls provided. To remove a rule completely from the list, click Remove. Note that removed rules are not deleted from the catalog, they are just disassociated with your Virtual Server.
5.For non-http protocols, you can specify whether the rule should be executed just once (against the first request or response), or against every request and response in the protocol dialogue.
This option is not necessary for HTTP virtual servers because HTTP is a single request-response protocol, and requests within a keepalive connection are processed independently.
You can test the effect of a new rule by enabling and disabling it for your test Virtual Server.