This is an old revision of the document!
Setting up a Proxy on the LiteSpeed Web ADC Context Level
Requirements
- LiteSpeed Web ADC on a load balancer server
- Two web servers.
Use Case Example
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.example.com/
- Back-end:
https://test.example.com/admin-panel/
The goal is:
- user requests
https://test.example.com
---> LiteSpeed ADC ---> front-end server - user requests
https://test.example.com/admin-panel/
---> LiteSpeed ADC ---> back-end server
Both ends should use same database server and network file system.
Configuration
Step 1
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 [root@test ~]# vi /etc/hosts [root@test ~]# curl http://test.example.com/admin-panel/ Hello World from back-end server [root@test ~]#
Step 2
Create two clusters in ADC WebAdmin console.
In this example they are named front-end
and back-end
.
Add a worker for each cluster.
For Type, choose HTTP
or HTTPS
, and the corresponding port will be set to 80 or 443, respectively. You 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.
Step 3
After the two clusters are created, add a new virtual host. Only /admin-panel/
is going to be proxied to back-end
, so the Default Cluster for this domain is front-end
.
Create a context.
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
.
Step 4
Step 5:
Save and restart the ADC, and check the results.
Visit test.example.com
:
Visit test.example.com/admin-panel/
:
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:
RewriteCond %{REQUEST_URI} !litespeed2 [NC] RewriteRule "(.*)" "litespeed2/$1" [L,E=Proxy-Host:different.domain.com]
E=Proxy-Host
flag is needed if backend is served on different domain.