How to Configure Advanced Load Balancer

During the configuration of a Load balancer, we have to select the option of load balancer backend type. Classic load balancing in its simplest term distributes the incoming traffic across multiple compute nodes based on balancing policy. Your load balancer IP serves as a single point of contact for your clients increasing the availability of your application. While in Advance load balancing, We will be able to define advance access rules on path-based and Host-based conditions.

../../_images/alb1.png

The access rules and routing rule that we define will determine how the load balancer will route requests to the backend servers.

Advance Access rule

To create a new access rule, Click on Add New rule

../../_images/alb2.png

Access rules can be added based on two conditions. Path-based condition and Host-based condition. Enter The Name of Access rule, Select the condition and Path/URL details.

  • Path Based Condition - You can use path conditions to define rules that route requests based on the URL in the request. The path pattern is applied only to the path of the URL, not to its query parameters. For example, In the below image the path is added e2enetworks.com/test

1. Exact Match : An exact match will only match the exact word “pathbase”.

Example: “pathbase”

2. Suffix match: A suffix match will match any word that ends with “pathbase”.

Example: “datapathbase”, “sourcepathbase”, “projectpathbase”

3. Prefix match: A prefix match will match any word that begins with “pathbase”.

Example: “pathbasefolder”, “pathbaseconfig”, “pathbasedirectory”

4. Regex match: A regular expression can be used to match words that contain “pathbase”.
Example: bw*pathbasew*b:

This regular expression will match any word that contains “pathbase” as a separate word. For example: “pathbasefile”, “mypathbaseproject”, “datapathbaseconfig”, “pathbase123”.

../../_images/pathbase_acl.png
5. Exact case sensitive match: An exact match will only match the exact word “pathbase” with the same capitalization.

Example: “pathbase” (will match), “PathBase” (will not match)

6. Suffix case sensitive match: A suffix match will match any word that ends with “pathbase”, with the same capitalization.

Example: “datapathbase” (will match), “pathbaseconfig” (will match), “pathBaseDirectory” (will not match)

  1. Prefix case sensitive match: A prefix match will match any word that begins with “pathbase”, with the same capitalization.

    Example: “pathbaseFolder” (will match), “pathbasedirectory” (will match), “PathBaseConfig” (will not match)

  2. Regex case sensitive match: A regular expression can be used to match words that contain “pathbase”, with the same capitalization.

    Example: bw*pathbasew*b This regular expression will match any word that contains “pathbase” as a separate word, with the same capitalization. For example: “pathbasefile” (will match), “mypathbaseProject” (will match), “dataPathBaseConfig” (will not match)

../../_images/case_sensetive_path.png
  • Host Based Condition - You can use host conditions to define rules that route requests based on the hostname in the host header known as host-based routing. For example, In below image, the host is added as test.e2enetworks.com

1. Prefix matching: A prefix is a group of letters that appears at the beginning of a word. To perform prefix matching on “hostbase,” you would look for words that start with a certain set of letters.
For example:

Prefix “host”: “hostname”, “hosting”, “hostile” Prefix “hos”: “hospital”, “hostess”, “hose”

2. Suffix matching: A suffix is a group of letters that appears at the end of a word. To perform suffix matching on “hostbase,” you would look for words that end with a certain set of letters.

For example:

Suffix “base”: “database”, “homebase”, “knowledgebase” Suffix “host”: “ghost”, “hostess”, “host”

3. Regex match: A regular expression can be used to match words that contain “hostbase”.
For example:

bw*pathbasew*b

Let’s break down this regular expression:

  1. b matches a word boundary, which ensures that we only match “hostbase” as a separate word and not as part of another word.

  2. w* matches zero or more word characters (letters, digits, or underscores).

  3. hostbase matches the literal string “hostbase”.

  4. w* matches zero or more word characters after “hostbase”.

  5. b matches another word boundary to ensure that we have matched the complete word.

So this regular expression will match words like “hostbase”, “ghosthostbase”, “hostbase123”, “myhostbaseproject”, and so on.

../../_images/hostbase_acl.png

Query parameters: Query parameters are used in web development to pass data from a client to a server through the URL. Depending on the type of data you need to pass, you can use different types of query parameters, such as exact match, prefix match, suffix match, or regular expression (regex) match. Here are some examples of each:

1. Exact match: This type of query parameter is used when you want to match a specific value exactly. For example, if you have a web application that displays information about different users, you could use an exact match query parameter to retrieve information about a specific user by their ID. Here’s an example URL:

https://example.com/users?id=123

In this case, the query parameter is “id=123”, which is an exact match for the user ID “123”.

2. Prefix match: This type of query parameter is used when you want to match values that start with a specific string. For example, if you have a search feature on your website that allows users to search for products by name, you could use a prefix match query parameter to retrieve all products that start with a specific string. Here’s an example URL:

https://example.com/search?query=phone

In this case, the query parameter is “query=phone”, which is a prefix match for any products that start with the string “phone”.

3. Suffix match: This type of query parameter is used when you want to match values that end with a specific string. For example, if you have a web application that displays information about different files, you could use a suffix match query parameter to retrieve all files that end with a specific file extension. Here’s an example URL:

https://example.com/files?type=pdf

In this case, the query parameter is “type=pdf”, which is a suffix match for any files that end with the “.pdf” file extension.

4. Regex match: This type of query parameter is used when you want to match values based on a complex pattern using regular expressions. For example, if you have a web application that searches for articles based on complex search criteria, you could use a regex match query parameter to retrieve articles that match a specific pattern. Here’s an example URL:

https://example.com/articles?search=python++programming

In this case, the query parameter is “search=python++programming”, which is a regex match for articles that contain the exact phrase “python++programming”. Note

that the plus signs (+) are escaped with a backslash () to match them literally.

5. Exact match case-sensitive: This type of query parameter is used when you want to match a specific value exactly, and you want the match to be case-sensitive. For example, if you have a web application that displays information about different users, and the user IDs are case-sensitive, you could use an exact match case-sensitive query parameter to retrieve information about a specific user by their ID. Here’s an example URL:

https://example.com/users?id=USER123

In this case, the query parameter is “id=USER123”, which is an exact match case-sensitive for the user ID “USER123”.

6. Prefix match case-sensitive: This type of query parameter is used when you want to match values that start with a specific string, and you want the match to be case-sensitive. For example, if you have a search feature on your website that allows users to search for products by name, and the product names are case-sensitive, you could use a prefix match case-sensitive query parameter to retrieve all products that start with a specific string. Here’s an example URL:

https://example.com/search?query=phone

In this case, the query parameter is “query=phone”, which is a prefix match case-insensitive for any products that start with the string “phone”.

7. Suffix match case-sensitive: This type of query parameter is used when you want to match values that end with a specific string, and you want the match to be case-sensitive. For example, if you have a web application that displays information about different files, and the file extensions are case-sensitive, you could use a suffix match case-sensitive query parameter to retrieve all files that end with a specific file extension. Here’s an example URL:

https://example.com/files?type=PDF

In this case, the query parameter is “type=PDF”, which is a suffix match case-sensitive for any files that end with the “.PDF” file extension.

8. Regex match case-sensitive: This type of query parameter is used when you want to match values based on a complex pattern using regular expressions, and you want the match to be case-sensitive. For example, if you have a web application that searches for articles based on complex search criteria, and the search criteria are case-sensitive, you could use a regex match case-sensitive query parameter to retrieve articles that match a specific pattern. Here’s an example URL:

https://example.com/articles?search=Python++Programming

In this case, the query parameter is “search=Python++Programming”, which is a regex match case-sensitive for articles that contain the exact phrase “Python++Programming”. Note that the plus signs (+) are escaped with a backslash () to match them literally.

../../_images/query_param_acl.png

HTTP request method : HTTP request method matching is a feature commonly used in load balancers to direct incoming requests to specific servers or services based on the HTTP method used in the request. Here are some examples of how HTTP request method matching can be used in a load balancer:

1. Match GET requests: This type of HTTP request method matching is used to direct all incoming GET requests to a specific server or service. For example, if you have a web application that serves static content from a dedicated server, you could use a load balancer to match all incoming GET requests and direct them to that server.

2. Match POST requests: This type of HTTP request method matching is used to direct all incoming POST requests to a specific server or service. For example, if you have a web application that handles form submissions on a dedicated server, you could use a load balancer to match all incoming POST requests and direct them to that server. http-request allow if { method POST }

3. Match PUT requests: This type of HTTP request method matching is used to direct all incoming PUT requests to a specific server or service. For example, if you have a web application that handles file uploads on a dedicated server, you could use a load balancer to match all incoming PUT requests and direct them to that server. Here’s an example configuration in the load balancer:

../../_images/httprequest_acl.png

Source IP matching: Source IP matching is a feature commonly used in load balancers to direct incoming requests to specific servers or services based on the source IP address of the request. Here’s an example of how source IP matching can be used in a load balancer.

Match requests from a specific IP address: This type of source IP matching is used to direct all incoming requests from a specific IP address to a specific server or service. For example, if you have a client that is accessing your application from a dedicated IP address, you could use a load balancer to match all incoming requests from that IP address and direct them to a specific server.

Match requests from a range of IP addresses: This type of source IP matching is used to direct all incoming requests from a range of IP addresses to a specific server or service. For example, if you have a set of servers that are optimized for handling requests from a specific geographic region, you could use a load balancer to match all incoming requests from that region and direct them to those servers. Here’s an example configuration in the load balancer:

../../_images/source_ip_acl.png

Backend Resource Details

In Backend Resource Details, We need to configure the backend connection of your load balancer as per your requirement.

You can specify a name or tag to group backend nodes and it will help categorize your node

  • To add a backend, Click on Add backed and enter the backend name.

../../_images/alb4.png
  • To add Backend server, click on Edit backend Icon and backend resource details.

../../_images/alb5.png
  • In the Node Details section, you need to specify the details of the virtual nodes you wish to register behind the Load Balancer.

  • You can use the ‘+ Add node’ button to add more node detail to the load balancer.

../../_images/alb6.png

Similarly, You need to add the required backend for your Load Balancer

../../_images/alb7.png

Routing Rule

Once, Access rule and Backend resource details have been configured, click on Add rules and Select the Advance Rule, Condition and Backend Resources.

../../_images/alb8.png

The routing rules allow you to use rules conditions that use the route traffic to the desired backend resources.

In the above example, We have used the rules created is_testpath and is_testhost

for the condition true, We have route traffic to backend-server-1 and backend-server-2 respectively.