What Happened?
You want to forward HTTP requests from F5® Distributed Cloud Services to origin web servers depending on more parameters than just the hostname in the URL of the request including:
-
- URL path
- Query strings or
- Specific headers
Environment
- F5® Distributed Cloud Services
Answer/Resolution
We will use the example of a load-balancer forwarding requests to 4 different origin servers depending on the language chosen by the website visitor (2 servers responding with content in English, and 2 more responding with content in French), and will assume that in this case requests have a country code in the URL path (in the form of https://myexample.com/en-GB/, for instance).
We will create a Load-balancer with an empty origin pool section. In its Routes section, we will add as many Routes as needed to match every path, and each of these Routes will point to a different origin pool.
To create an origin pool:
- Make sure you start from the desired Namespace
- Navigate to Manage > Load Balancers > Origin pools
- Click Add Origin Pool
- Give it a name (We chose pool-english, here)
- Add as many Origin servers as you have for this pool (we have two)
- Make sure the port setting and the TLS setting are matching
- Repeat steps 3 to 6 with a pool-french pool.
To create a Load-balancer:
1. Navigate to Manage > Load Balancers > HTTP Load Balancers
2. Click Add HTTP load balancer
3. Give it a name (We chose "lb-i18n-myexample-com", here)
4. In the Basic Configuration section, set the domain (we used myexample.com here)
5. Choose the value of your choice for the Load Balancer Type
6. In the Routes Configuration below, click Configure
7. In the Routes form that appears, click on Add item
8. As a type of Route, select Simple Route
9. In the Path match drop-down menu, select Regex
10. Enter the string "\/en-[A-Z]{2}\/.*" (without the quotes) as the regular expression (or Regex). This allows to match requests for https://myexample.com/en-US/ and https://myexample.com/en-GB.
11. In the Origin Pools section, click Add item, and find the pool-english object created previously.
12. Repeat steps 2 to 6 for the route-french route, using the string "\/fr-[A-Z]{2}\/.*" as Regex.
13. You should end up with the following:
14. Click Apply
15. Click Save and Exit to save the load-balancer.
Your internationalized load-balancer is now created. If it was not or you are confused by some of the steps, contact support.
Related Content