Text in Expression Editor:
starts_with(http.request.uri.path, "/team/calendar/")Value after Destination Port > Rewrite to:
8081Create an origin rule to change the destination port.
The following origin rule overrides the destination port to 8081 for all requests where the URI path starts with /team/calendar/.
Text in Expression Editor:
starts_with(http.request.uri.path, "/team/calendar/")Value after Destination Port > Rewrite to:
8081The following example sets the rules of an existing phase ruleset ($RULESET_ID) to a single origin rule — overriding the port of incoming requests — using the Update a zone ruleset operation. The response will contain the complete definition of the ruleset you updated.
Required API token permissions
Response Compression WriteConfig Settings WriteDynamic URL Redirects WriteCache Settings WriteCustom Errors WriteOrigin WriteManaged headers WriteZone Transform Rules WriteMass URL Redirects WriteMagic Firewall WriteL4 DDoS Managed Ruleset WriteHTTP DDoS Managed Ruleset WriteSanitize WriteTransform Rules WriteSelect Configuration WriteBot Management WriteZone WAF WriteAccount WAF WriteAccount Rulesets WriteLogs WriteLogs Writecurl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/$RULESET_ID \ --request PUT \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ --json '{ "rules": [ { "expression": "starts_with(http.request.uri.path, \"/team/calendar/\")", "description": "Origin rule for the team calendar application", "action": "route", "action_parameters": { "origin": { "port": 8081 } } } ] }'{ "result": { "id": "<RULESET_ID>", "name": "Origin Rules ruleset", "description": "Zone-level ruleset that will execute origin rules.", "kind": "zone", "version": "2", "rules": [ { "id": "<RULE_ID>", "version": "1", "action": "route", "action_parameters": { "origin": { "port": 8081 } }, "expression": "starts_with(http.request.uri.path, \"/team/calendar/\")", "description": "Origin rule for the team calendar application", "last_updated": "2022-06-03T14:42:04.219025Z", "ref": "<RULE_REF>" } ], "last_updated": "2022-06-03T14:42:04.219025Z", "phase": "http_request_origin" }, "success": true, "errors": [], "messages": []}