Creating a Layer7 policy using OpenStack Terminal Client

We recommend first reading our guide on layer 7 policies to get a better understanding of how they work. To create a layer 7 policy using the OpenStack Terminal Client, follow the below steps.

  • Run this command: openstack loadbalancer listener list. Save the name of the listener to which you want to add the rule.

  • Run this command: openstack loadbalancer l7policy create --action REDIRECT_TO_URL --redirect-url [http(s)://DOMAIN] --name [POLICY_NAME] [LISTENER_NAME], replacing the values in angle brackets. This sets up the policy.

  • Run this command: openstack loadbalancer l7rule create --compare-type STARTS_WITH --type PATH --value / [POLICY_NAME]. This sets up the rule.

  • Run this command: openstack loadbalancer l7rule show [POLICY_NAME] [RULE_ID]. Replace the items in angle brackets (the RULE_ID is from the previous commands output). Once the “operating_status” says “ONLINE”, the rule should be live.

Note

Above is an example of a rule which would perform a redirect. More information on the available rules can be read in detail here.