Saturday, May 22, 2021

OCI Load Balancer redirection

 We all are aware that load balancers helps in distributing the requests to the backend servers based upon certain algorithms. OCI Load Balancers helps in achieving high availability and scalability. Based upon our requirement we can induce multiple policies and application level health checks in OCI Load Balancer. For information about OCI Load Balancer, you can go through Load Balancer. In this specific blog, i have tried to give the demonstration on how using Load Balancer advanced configurations such as Path Routes, Hostnames and Rule sets, we can redirect the request to specific backend server. In my earlier posts https://samappsdba.blogspot.com/2020/05/configuring-oci-load-balancer-for-ebs.html,i have explained how we can create a basic Load balancer in OCI.


I already have one public load balancer and one backend sets which comprises of two web servers webserver1 and webserver2. The web servers have the files webserver1.html and webserver2.html under the  /var/www/html path. 




As of now, if i type the public IP address of LB in the browser, it redirects me to the backend web server1 and webserver 2 as the algorithm choosen is Round Robin



And hit the ip address of the LB and it redirects me to second web server




 Upto this point Load balancer has the basic settings. Now i have two domains webserver1.tk and webserver2.tk 

The purpose would be to redirect the load to webserver1(webserver1.html) for the requests coming to webserver1.tk and redirect the load to webserver2(webserver2.html) for the requests coming to webserver2.tk. The handling of DNS queries are being served by OCI DNS Zones is out of scope for this post. I will cover the same in future posts.

First, under load balancer, i will create the specific hostnames.

Next, create 2 Path Route Set




next, create the rule sets








Now edit the listener which was created initially as part of OCI Load balancer setup and add an another listener. These two listeners will cater to two hostnames.



And then add the second listener








Now, if i hit the webserver.tk, the request is getting redirected to webserver/webserver1.html


test the same for webserver2.tk




There are many other advanced configurations which we can use with our OCI Load Balancer for which we can go through the Advanced OCI LB Config. The post was all about how using one flexible load balancer, we can serve multiple urls using hostnames, Path Routes and Rule sets. Hope this post helps someone. Keep learning cloud.














1 comment: