Configure the OCI Load Balancer to access multiple applications (Instances) using different Domain Names

From Iwan
Jump to: navigation, search


In this article, I am going to explain how you can use the OCI Load Balancer (in a Hub and Spoke Network Architecture) to redirect network traffic to different backend sets (Instances) based on a URL (Domain name.)

Profile-lb-multiple-domains.png

This tutorial will use the previously written tutorials below as its main foundation:

  1. [Deploy a Windows Instance in Oracle Cloud Infrastructure]
  2. [Install a pfSense Firewall in Oracle Cloud Infrastructure]
  3. [Route Hub and Spoke VCN with pfSense Firewall in the Hub VCN]
  4. [Connect On-premises to OCI using an IPSec VPN with Hub and Spoke VCN Routing Architecture]
  5. [Add LB and WAF to a Hub to an Hub and Spoke VCN Routing architecture]

In the [previous article], we tested the Load Balancer with a Web Application Firewall (WAF) Policy we can take the Load Balancing testing one step further.

Let's assume we have dedicated our Spoke VCNs to different customers (or applications). Now we want to use ONE SINGLE LOAD BALANCER to redirect traffic (by the Load Balancer) to these different Customer Instances (inside the different) Spoke VCNs based on the URL that is used externally (from the Internet).

Below you will see an illustration of the traffic flow when you use different URLs to access different Instances (or applications) from the internet.

  • Blue: This is the traffic flow for the first customer using the URL: customer-a.iwanhoogendoorn.nl to access the Instance in VCN-A.
  • Purple: This is the traffic flow for the first customer using the URL: customer-b.iwanhoogendoorn.nl to access the Instance in VCN-B.
  • Green: This is the traffic flow for the first customer using the URL: customer-c.iwanhoogendoorn.nl to access the Instance in VCN-C.

The Steps

  • [ ] STEP 01: Change the WAF Policy
  • [ ] STEP 02: Configure the DNS for the (public) domain names
  • [ ] STEP 03: Configure Hostnames on the OCI Load Balancer
  • [ ] STEP 04: Create multiple Back End Sets on the OCI Load Balancer
  • [ ] STEP 05: Create multiple Listeners on the OCI Load Balancer
  • [ ] STEP 06: Test out connectivity with the different (public) domain names

90e407cdda7bdc13a5f8e746c4e48ad6.png

STEP 01 - Change the WAF Policy

  • First, let's change the WAF policy to allow traffic again.
  • Go to the Web Application Firewall and select the policy we created earlier.

6bf861b1cd6d70ca540bdc089e3a8a75.png

  • Click on Access control.
  • Click on the Manage request control button.

5ba6691713529d9b7f904a3280cb882c.png

  1. Click the Edit button to edit the Access Rule.
  2. Change the action to Pre-configured Allow Action to allow all the traffic again.
  3. Click on the Save changes button.

B39e63c6af1076250bd5557a918fb9de.png

STEP 02 - Configure the DNS for the public domain names

Use your DNS Server to configure the domain names (hostnames/URLs) and map this to the PUBLIC IP address of the Load Balancer. In my case below you will see the following mapping.

The domain name that I am testing with is: iwanhoogendoorn.nl

Name Type Value
customer-a A 144.xxx.xxx.xxx (Public IP address of the OCI Load Balancer)
customer-b A 144.xxx.xxx.xxx (Public IP address of the OCI Load Balancer)
customer-c A 144.xxx.xxx.xxx (Public IP address of the OCI Load Balancer)

This will create the following (sub) domains:

  • customer-a.iwanhoogendoorn.nl
  • customer-b.iwanhoogendoorn.nl
  • customer-c.iwanhoogendoorn.nl


F2801f75fe007e4645fd5f9a6cca969c.png

STEP 03 - Configure Hostnames on the OCI Load Balancer

  • Let's first configure the hostnames on the OCI Load Balancer.
  1. Browse to Networking > Load Balancers.
  2. Select the Load Balancer that we previously created.

E42dc1bbe5c057844c1e68a93dbdaaf7.png

  • Make sure you can see the Load Balancer details.
  • Scroll down.

Dfc822a344ab210457ede7631b272aa1.png

  1. Click on Hostnames.
  2. Click on the Create Hostname button.

10e780f239be3a546883c00be517c5b5.png

  1. Provide a name for the hostname.
  2. Provide a hostname, in my case this will be customer-a.iwanhoogendoorn.nl.
  3. Click on the Create button.

47a66d862a3aacab083ebae37c1d7941.png

  • Notice that the Work request has been submitted, and click on the Close button.

8169e7e675533950b537ffa0ebab2234.png

  1. Notice that the hostname for Customer A has been created successfully.
  2. Click on the Create Hostname button.

40a24739f3b35fc3957fd38b743dd78b.png

  1. Provide a name for the hostname.
  2. Provide a hostname, in my case this will be customer-b.iwanhoogendoorn.nl.
  3. Click on the Create button.

62a7d31f4c6638e5d204e1320c7f5176.png

  • Notice that the Work request has been submitted, and click on the Close button.

4629a5e97561c8b7d38987d5d7ec734a.png

  1. Notice that the hostname for Customer B has been created successfully.
  2. Click on the Create Hostname button.

Da4c45c4dd2cb91ef56d54a2808295f7.png

  1. Provide a name for the hostname.
  2. Provide a hostname, in my case this will be customer-c.iwanhoogendoorn.nl.
  3. Click on the Create button.

9688c1b5739fb4e07a62fcace7fc40bc.png

  • Notice that the Work request has been submitted, and click on the Close button.

F13e8db4aa2516e03bc21896efc28c41.png

  1. Notice that the hostname for Customer C has been created successfully.
  2. Click on the Create Hostname button.

Ad962a1d81a3068037eac6f9d711e31f.png

STEP 04 - Create multiple Back End Sets on the OCI Load Balancer

  • Let's now configure the Backend sets on the OCI Load Balancer.
  • We will create three backend sets, one for each customer.
  1. Click on Backend sets.
  2. Click on the Create backend set button.

F79abd1b3d812e03326db1973ec194bd.png

  1. Provide a name for the Backend set for Customer A.
  2. Scroll down.

9b043ab0742b14c69ab604b195618608.png

  1. Select HTTP as the protocol for the health check.
  2. Specify port 80 as the port for the health check.
  3. Specify / for the URL path.
  4. Click on the Create backend set button.

347505f8b843d66ae444717e3a0769e3.png

  • Notice that the Work request has been submitted, and click on the Close button.

56d4b67a908f2b1b2673da884c653b6a.png

  1. Click on the Create backend set button.
  2. Provide a name for the Backend set for Customer B.
  3. Scroll down.

B29ec1daf38bdc11272b456187d6fefb.png

  1. Select HTTP as the protocol for the health check.
  2. Specify port 80 as the port for the health check.
  3. Specify / for the URL path.
  4. Click on the Create backend set button.

C57bc4dbb2b7839dcc97e5c853ca8393.png

  • Notice that the Work request has been submitted, and click on the Close button.

5b8eb666a1c0dd098fb74384e1df35ba.png

  1. Click on the Create backend set button.
  2. Provide a name for the Backend set for Customer C*.
  3. Scroll down.

Bfbbfd469b4b8e77bdfd42d325e4edab.png

  1. Select HTTP as the protocol for the health check.
  2. Specify port 80 as the port for the health check.
  3. Specify / for the URL path.
  4. Click on the Create backend set button.

8cda00485068caaf7babcc9932ae5563.png

  • Notice that the Work request has been submitted, and click on the Close button.

01ce607f41adf577e0f3cc76322331b5.png

  1. Notice that all the backend sets are created for all customers.
  2. Notice that the Health is showing up as Incomplete. This is because we still need to specify the actual backend where the health check can be performed.

2f2895046f926ef069e53e611f098b78.png

  • Click on the Backend set for Customer A.

54737c2460997ae52e8b4bdabbb22ec9.png

  • Scroll down.

3759b9945b0138f62bd561a04c41f6a1.png

  1. Click on Backends.
  2. Click on the Add Backends button.

C1e4005ba45d56e437db597b3478f4c8.png

  1. Select the Instance that is hosted in the Spoke VCN A.
  2. Click on the Add button.

47a04e387a7f695a8ddd19ea17e7fde1.png

  • Notice that the Work request has been submitted, and click on the Close button.

D612667e86e02800be77a1637617b476.png

  • When you have added the Instance to the Backend set the initial health status will be Pending.

F4a1e144e5c5d4e27fb3f48e9b2791c3.png

  • After a minute the Health status will change from pending to OK.

10806b4961b930e73dce30ab97227648.png

  1. Scroll up.
  2. Click on the Backend sets breadcrumbs menu to return to the Backend sets page.

7c0ef69d091b6856006a59ae8f61a7d2.png

  • Click on the Backend set for Customer B.

9192296e9ce18b8fbbff7685ee735502.png

  1. Click on Backends.
  2. Click on the Add Backends button.

E94da2b2f5902439cd1475f68d4d62fb.png

  1. Select the Instance that is hosted in the Spoke VCN B.
  2. Click on the Add button.

321ea82583e6e729038eb8b25c18b783.png

  • Notice that the Work request has been submitted, and click on the Close button.

2f63c61ee6bd2e68d8713718b66e3fc4.png

  • When you have added the Instance to the Backend set the initial health status will be Pending.

A7b8eb707dfff9e491454e194077f101.png

  • After a minute the Health status will change from pending to OK.

715810706da00d159917d871cd5e7070.png

  1. Scroll up.
  2. Click on the Backend sets breadcrumbs menu to return to the Backend sets page.

5d30ddd58d3441c4b65a5722f0360900.png

  • Click on the Backend set for Customer C.

F2f30ad7e7b5d97342a4e987e671dfca.png

  1. Click on Backends.
  2. Click on the Add Backends button.

2f492767b637ef7229d62a8a5d1d6b1e.png

  1. Select the Instance that is hosted in the Spoke VCN C.
  2. Click on the Add button.

00b2c99bd1cb9a5df6d4e0f46d212dba.png

  • Notice that the Work request has been submitted, and click on the Close button.

85cd2c49d946058c0ffd59bb11692a8f.png

  • When you have added the Instance to the Backend set the initial health status will be Pending.

5abcee8ff39e23bfddebae4d7e7af93a.png

  • After a minute the Health status will change from pending to OK.

0c75707cfa710ad450ec84d0172cb6ad.png

  1. Scroll up.
  2. Click on the Backend sets breadcrumbs menu to return to the Backend sets page.

6379c0a39f61395e424d8c102b2f8f39.png

STEP 05 - Create multiple Listeners on the OCI Load Balancer

  • Let's now configure the Listeners for each customer based on the domain names.
  1. Click on Listeners.
  2. Click on the Create listener button.

Adb73fa83574e403f25f705bd9c67525.png

  1. Provide a name for the listener or Customer A.
  2. Select HTTP for the protocol.
  3. Specify port 80.
  4. Select the hostname for Customer A we created earlier.
  5. Select the backend set for Customer A we created earlier.
  6. Click on the Create listener button.

4f93fbb27558b422d5b912fbd6761e13.png

  • Notice that the Work request has been submitted, and click on the Close button.

07f24087c91de8396b94137ea965eae9.png

  1. Notice that the listener for Customer A is created successfully.
  2. Click on the Create listeners button.

7cf1588bd4714c9cce262b9ed3e44be0.png

  1. Provide a name for the listener or Customer B.
  2. Select HTTP for the protocol.
  3. Specify port 80.
  4. Select the hostname for Customer B we created earlier.
  5. Select the backend set for Customer B we created earlier.
  6. Click on the Create listener button.

C2bba012f837ca20edd9ab389cdb49bd.png

  • Notice that the Work request has been submitted, and click on the Close button.

042b779a4dc91e1a5ad8d42549f99933.png

  1. Notice that the listener for Customer B is created successfully.
  2. Click on the Create listeners button.

D27c555c64b7bebd6ef97418621d348c.png

  1. Provide a name for the listener or Customer C.
  2. Select HTTP for the protocol.
  3. Specify port 80.
  4. Select the hostname for Customer C we created earlier.
  5. Select the backend set for Customer C we created earlier.
  6. Click on the Create listener button.

Df3a65346efc4af6b2beaf9a492e9b14.png

  • Notice that the Work request has been submitted, and click on the Close button.

41fcfb3a8548705c5be0bf32ed2fa1f7.png

  1. Notice that the listener for Customer C is created successfully.

1ddb35ac0d2483ae05dfd5e0eb1fa6a1.png

STEP 06 - Test out connectivity with the different public domain names

  • Open a new browser.
  1. Type/Paste in the URL for customer A (customer-a.iwanhoogendoorn.nl).
  2. Notice that the Load Balancer redirects the traffic to the Instance in the Spoke VCN A.

C4112c38be4d9bdb8d6605120b5317f6.png

  • Open a new browser (tab).
  1. Type/Paste in the URL for customer B (customer-b.iwanhoogendoorn.nl).
  2. Notice that the Load Balancer redirects the traffic to the Instance in the Spoke VCN B.

B08123e6118df4f99f02bcf17b66bfd7.png

  • Open a new browser (tab).
  1. Type/Paste in the URL for customer C (customer-c.iwanhoogendoorn.nl).
  2. Notice that the Load Balancer redirects the traffic to the Instance in the Spoke VCN C.

Cb725ad78466a560a49d836fc0c0dd3e.png

We have now successfully tested that the Load Balancer distributing the traffic based on a different URL (Hostname).

Conclusion

In this article, we have configured the load balancer so that it is capable of redirecting traffic based on different customer hostnames (URLs).