Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:lslb:context_proxy [2018/11/13 15:30]
qtwrk [Step 3:]
litespeed_wiki:lslb:context_proxy [2021/01/09 01:47]
qtwrk
Line 1: Line 1:
-=======LiteSpeed ADC proxy on context level.=======+====== ​Setting up a Proxy on the LiteSpeed ​Web ADC Context Level ======
  
-=====Requirement:​=====+===== Requirements ​=====
  
-LiteSpeed ADC on load balancer server ​, 2 web servers.+  * LiteSpeed ​Web ADC on load balancer server 
 +  * Two web servers.
  
-Use case exmaple:+===== Use Case Example =====
  
-very heavy site that user wants to separate ​front-end and back-end.+You have a very heavy site, and so you want to lighten the load by hosting the front-end and back-end ​on different servers.
  
-Front-end: https://​test.litespeedtech.com/  ​, back-end: https://​test.litespeedtech.com/​admin-panel/​+  * Front-end: ​''<​nowiki>​https://​test.example.com/</​nowiki>''​ 
 +  * Back-end: ''<​nowiki>​https://​test.example.com/​admin-panel/​</​nowiki>''​
  
 The goal is: The goal is:
  
-  user to https://​test.litespeedtech.com ---> LiteSpeed ADC ---> front-end server +  ​user requests ''<​nowiki>​https://​test.example.com</​nowiki>'' ​---> LiteSpeed ADC ---> front-end server 
-  user to https://​test.litespeedtech.com/​admin-panel/​ ---> LiteSpeed ADC ---> back-end server+  ​user requests ''<​nowiki>​https://​test.example.com/​admin-panel/​</​nowiki>'' ​---> LiteSpeed ADC ---> back-end server
  
 Both ends should use same database server and network file system. Both ends should use same database server and network file system.
  
-====Step 1:====+===== Configuration =====
  
-Make sure both server are set up correctly , use local host file to bypass DNS for testing purpose.+====Step 1====
  
-  ​[root@test ~]# curl http://​test.litespeedtech.com+Make sure both servers are set up correctly. Use local host file to bypass DNS for testing purposes. 
 + 
 +  ​[root@test ~]# curl http://​test.example.com
   Hello World from front-end server   Hello World from front-end server
   [root@test ~]# vi /etc/hosts   [root@test ~]# vi /etc/hosts
-  [root@test ~]# curl http://​test.litespeedtech.com/​admin-panel/​+  [root@test ~]# curl http://​test.example.com/​admin-panel/​
   Hello World from back-end server   Hello World from back-end server
   [root@test ~]#   [root@test ~]#
  
 +====Step 2====
  
-====Step 2:==== +Create ​two clusters in ADC WebAdmin ​console.
- +
-Create ​clusters in ADC webadmin ​console. +
  
 {{:​litespeed_wiki:​lslb:​adc-context-1.png|}} {{:​litespeed_wiki:​lslb:​adc-context-1.png|}}
  
-In this example they are named as ''​front-end''​ and ''​back-end''​+In this example they are named ''​front-end''​ and ''​back-end''​.
  
 {{:​litespeed_wiki:​lslb:​adc-context-2.png|}} {{:​litespeed_wiki:​lslb:​adc-context-2.png|}}
  
-And then add worker+Add a worker ​for each cluster.
  
 {{:​litespeed_wiki:​lslb:​adc-context-3.png|}} {{:​litespeed_wiki:​lslb:​adc-context-3.png|}}
  
-Type choose HTTP or HTTPS , so is corresponding port to be 80 or 443.  this port can be any other port as long as it works with HTTP or HTTPS, and add IP in node list.+For **Type**, choose ​''​HTTP'' ​or ''​HTTPS''​and the corresponding port will be set to 80 or 443, respectivelyYou can override the port numbers, ​as long as your choice ​works with HTTP or HTTPS as needed. 
 + 
 +Add the IP address to **Node Address List**.
  
 {{:​litespeed_wiki:​lslb:​adc-context-4.png|}} {{:​litespeed_wiki:​lslb:​adc-context-4.png|}}
  
-After front-end cluster, same process for back-end cluster.+====Step 3====
  
-====Step 3:==== +After the two clusters are created, ​add new virtual host. Only ''​/​admin-panel/​'' ​is going to be proxied to ''​back-end''​, so the **Default Cluster** ​for this domain is ''​front-end''​.
- +
-After clusters are created , now create ​a virtual host, since only **/​admin-panel/​** is going to be proxied to back-end , so main cluster ​for this domain is ''​front-end''​+
  
 {{:​litespeed_wiki:​lslb:​adc-context-5.png|}} {{:​litespeed_wiki:​lslb:​adc-context-5.png|}}
  
-Now create ​a context.+Create ​a context.
  
 {{:​litespeed_wiki:​lslb:​adc-context-6.png|}} {{:​litespeed_wiki:​lslb:​adc-context-6.png|}}
  
-Set URI to **/​admin-panel/​** please attach **/** at end so every URI inside it will also be proxied, and choose ​**back-end** cluster.+Set **URI** to ''​/​admin-panel/​''​making sure to include the ''​/'' ​at the end. This ensures ​so every URI in that path will also be proxied
 + 
 +Set **Cluster** to ''​back-end''​.
  
 {{:​litespeed_wiki:​lslb:​adc-context-7.png|}} {{:​litespeed_wiki:​lslb:​adc-context-7.png|}}
  
-====Step 4:====+====Step 4====
  
-Now create ​listener and add domain ​into it.+Create a listener and add the ''​test.example.com'' ​domain ​to it.
  
 {{:​litespeed_wiki:​lslb:​adc-context-8.png|}} {{:​litespeed_wiki:​lslb:​adc-context-8.png|}}
Line 73: Line 77:
 ====Step 5:==== ====Step 5:====
  
-Save and restart ADC, and check the result+Save and restart ​the ADC, and check the results. 
 + 
 +Visit ''​test.example.com'':​
  
 {{:​litespeed_wiki:​lslb:​adc-context-9.png|}} {{:​litespeed_wiki:​lslb:​adc-context-9.png|}}
  
-And access to **/​admin-panel/​**+Visit ''​test.example.com/​admin-panel/​'':​
  
 {{:​litespeed_wiki:​lslb:​adc-context-10.png|}} {{:​litespeed_wiki:​lslb:​adc-context-10.png|}}
 +
 +
 +=====Context Proxy To Different Domain/​URLs:​=====
 +
 +in this example , we will proxy context URL https://​test.example.com/​litespeed/​ to https://​different.domain.com/​litespeed2/​
 +
 +====Step 1:=====
 +
 +This step will be exact same as above
 +
 +====Step 2:=====
 +
 +Create a new cluster if the `different.domain.com` is on different backend server, ​ this step can be ignored if the targeted domain is on same cluster.
 +
 +====Step 3:=====
 +
 +Create a new context ​
 +
 +**URI** to ''/​litespeed/''​
 +
 +**Cluster** to ''​back-end''​ as above , or newly created cluster in step 2
 +
 +**Enable Rewrite** to ''​Yes''​
 +
 +**Rewrite Base** to ''/'' ​   , this setting is required , in order to prevent the rewrite rule messes up with base.
 +
 +**Rewrite Rules** as follow:
 +
 +<​code>​
 +RewriteCond %{REQUEST_URI} !litespeed2 [NC]
 +RewriteRule "​(.*)"​ "​litespeed2/​$1"​ [L,​E=Proxy-Host:​different.domain.com]
 +</​code>​
 +
 +''​E=Proxy-Host''​ flag is needed if backend is served on different domain.
  • Admin
  • Last modified: 2021/01/11 21:12
  • by Lisa Clarke