Note:
- This tutorial requires access to Oracle Cloud. To sign up for a free account, see Get started with Oracle Cloud Infrastructure Free Tier.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
Configure the OCI Load Balancer to Access Multiple Instances using Different Domain Names
Introduction
In this tutorial, we will use the Oracle Cloud Infrastructure (OCI) Load Balancer in a Hub and Spoke network architecture to redirect network traffic to different backend sets (instances) based on URL or domain name.
Let us assume, we have dedicated our spoke VCNs to different customers or applications. 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 URL that is used externally from the internet.
The following image illustrates the traffic flow when you use different URLs to access different instances or applications from the internet.
- Blue traffic flow: This is the traffic flow for the first customer with URL:
customer-a.iwanhoogendoorn.nl
to access the instance in VCN-A. - Purple traffic flow: This is the traffic flow for the first customer with URL:
customer-b.iwanhoogendoorn.nl
to access the instance in VCN-B. - Green traffic flow: This is the traffic flow for the first customer with URL:
customer-c.iwanhoogendoorn.nl
to access the instance in VCN-C.
Objectives
- We will configure the load balancer so that it is capable of redirecting traffic based on different customer hostnames or URLs.
Prerequisites
-
Ensure you complete the following tutorials if you want to recreate the content in this tutorial.
Task 1: Change the OCI Web Application Firewall (WAF) Policy
Change the WAF policy to allow traffic.
-
Log in to the OCI Console, go to Web Application Firewall and select the policy created in this tutorial: Task 6: Install and Configure an OCI Web Application Firewall.
-
Click Access control and Manage request control.
- Click Edit to edit the access rule.
- Change the Action name to Pre-configured Allow Action to allow all the traffic.
- Click Save changes.
Task 2: Configure the Domain Name System (DNS) for the Public Domain Names
Use your DNS server to configure the domain names or hostnames or URLs and map them to the public IP address of the load balancer.
For this tutorial, the domain name that we are testing with is iwanhoogendoorn.nl
. You will see the following mapping.
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 subdomains:
customer-a.iwanhoogendoorn.nl
.customer-b.iwanhoogendoorn.nl
.customer-c.iwanhoogendoorn.nl
.
Task 3: Configure Hostnames OCI Load Balancer
-
Go to the OCI Console.
- Navigate to Networking and Load Balancers.
- Select the load balancer created in this tutorial: Task 5: Install an OCI Load Balancer.
-
Make sure you can see the load balancer details.
- Click Hostnames.
- Click Create Hostname.
- Enter a Name for the hostname.
- Enter a Hostname. For this tutorial, we are using
customer-a.iwanhoogendoorn.nl
. - Click Create.
-
Note that the work request has been submitted. Click Close.
- Note that the hostname for Customer A has been created successfully.
- Click Create Hostname.
- Enter a Name for the hostname.
- Enter a Hostname. For this tutorial, we are using
customer-b.iwanhoogendoorn.nl
. - Click Create.
-
Note that the work request has been submitted. Click Close.
- Note that the hostname for Customer B has been created successfully.
- Click Create Hostname.
- Enter a Name for the hostname.
- Enter a Hostname. For this tutorial, we are using
customer-c.iwanhoogendoorn.nl
. - Click Create.
-
Note that the work request has been submitted. Click Close.
- Note that the hostname for Customer C has been created successfully.
- Click Create Hostname.
Task 4: Create Multiple Backend Sets
Configure the backend sets for OCI Load Balancer.
-
We will create three backend sets, one for each customer.
- Click Backend sets.
- Click Create backend set.
- Enter a Name for the backend set for Customer A.
- Scroll down.
- Protocol: Select HTTP.
- Port: Enter port 80.
- URL path: Enter /.
- Click Create backend set.
-
Note that the work request has been submitted. Click Close.
- Click Create backend set.
- Enter a Name for the backend set for Customer B.
- Scroll down.
- Protocol: Select HTTP.
- Port: Enter port 80.
- URL path: Enter /.
- Click Create backend set.
-
Note that the work request has been submitted. Click Close.
- Click Create backend set.
- Enter a Name for the backend set for Customer C.
- Scroll down.
- Protocol: Select HTTP.
- Port: Enter port 80.
- URL path: Enter /.
- Click Create backend set.
-
Note that the work request has been submitted. Click Close.
- Note that all the backend sets are created for all customers.
- Note that the Health is showing Incomplete. This is because we still need to specify the actual backend where the health check can be performed.
-
Click backend set for Customer A.
-
Scroll down.
- Click Backends.
- Click Add Backends.
- Select the instance that is hosted in the spoke VCN A.
- Click Add.
-
Note that the work request has been submitted. Click Close.
-
When you have added the instance to the backend set the initial Health status will be Pending.
-
After a few minutes the Health status will change to OK.
- Scroll up.
- Click Backend sets to return to the backend sets page.
-
Click backend set for Customer B.
- Click Backends.
- Click Add Backends.
- Select the instance that is hosted in the spoke VCN B.
- Click Add.
-
Notice that the work request has been submitted. Click Close.
-
When you have added the instance to the backend set the initial Health status will be Pending.
-
After a few minutes the Health status will change to OK.
- Scroll up.
- Click Backend sets to return to the backend sets page.
-
Click backend set for Customer C.
- Click Backends.
- Click Add Backends.
- Select the instance that is hosted in the spoke VCN C.
- Click Add.
-
Note that the work request has been submitted. Click Close.
-
When you have added the instance to the backend set the initial Health status will be Pending.
-
After a few minutes the Health status will change to OK.
- Scroll up.
- Click Backend sets to return to the backend sets page.
Task 5: Create Multiple Listeners
-
Configure the listeners for each customer based on domain names.
- Click Listeners.
- Click Create listener.
- Name: Enter a listener name for Customer A.
- Protocol: Select HTTP.
- Port: Enter 80.
- Hostname: Select the hostname for Customer A created in Task 3.
- Backend set: Select the backend set for Customer A created in Task 3.
- Click Create listener.
-
Note that the work request has been submitted. Click Close.
- Note that the listener for customer A is created successfully.
- Click Create listeners.
- Name: Enter a listener name for Customer B.
- Protocol: Select HTTP.
- Port: Enter 80.
- Hostname: Select the hostname for Customer B created in Task 3.
- Backend set: Select the backend set for Customer B created in Task 3.
- Click Create listener.
-
Note that the work request has been submitted. Click Close.
- Note that the listener for customer B is created successfully.
- Click Create listeners.
- Name: Enter a listener name for Customer C.
- Protocol: Select HTTP.
- Port: Enter 80.
- Hostname: Select the hostname for Customer C created in Task 3.
- Backend set: Select the backend set for Customer A created in Task 3.
- Click Create listener.
-
Note that the work request has been submitted. Click Close.
-
Note that the listener for customer C is created successfully.
Task 6: Test the Connectivity with the Different Public Domain Names
-
Open a new browser tab.
- Enter the URL for customer A:
customer-a.iwanhoogendoorn.nl
. - Note that the load balancer redirects the traffic to the instance in the spoke VCN A.
- Enter the URL for customer A:
-
Open a new browser tab.
- Enter the URL for customer B:
customer-b.iwanhoogendoorn.nl
. - Note that the load balancer redirects the traffic to the instance in the spoke VCN B.
- Enter the URL for customer B:
-
Open a new browser tab.
- Enter the URL for customer C:
customer-c.iwanhoogendoorn.nl
. - Note that the load balancer redirects the traffic to the instance in the spoke VCN C.
- Enter the URL for customer C:
We have successfully tested the load balancer distributing the traffic based on a different URLs or hostnames.
Acknowledgments
- Author - Iwan Hoogendoorn (OCI Network Specialist)
More Learning Resources
Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.
For product documentation, visit Oracle Help Center.
Configure the OCI Load Balancer to Access Multiple Instances using Different Domain Names
G12131-02
July 2024