Skip to content

How to Set up LSWS as a Load Balancer

This example uses three servers:

  • back1.litespeedtech.com with IP 192.0.2.151
  • back2.litespeedtech.com with IP 192.0.2.152
  • load.litespeedtech.com with IP 192.0.2.153

back1 and back2 will act as two backend nodes, and load will act as a load balancer.

Verify the 3 Servers are Working

Visit each backend node and the load balancer one by one in your browser:

As seen in the screenshots, the three servers are deliberately set to display different content to distinguish them from each other.

Create External Apps

Create a new external app in the load balancer server's WebAdmin Console. This is can be done either at the server level or the vhost level.

In this example, we are using a vhost that we've named "load balancer." Navigate to Virtual Host > Load-balancer > External App and click Add.

Choose Type Web Server and click Next.

Set Name to back1 and Address to 192.0.2.151.

Since this example has two backend nodes, repeat the previous step to create another external app with Type Web Server, Name back2, and Address 192.0.2.152.

Now create another external app, and set Type to Load Balancer. Click Next.

Set Name to load-balancer, and Workers to proxy::back1,proxy::back2 (these names were created in the previous steps).

There should now be three external apps named load-balancer, back2, and back1.

Create a Context

Create a new context with Type Load Balancer.

For this example, we want a full-site proxy, so set URI to /. Set the Load Balancer to the one we just created at the vhost level: load-balancer.

Since the three servers are using three different domains, add the load.litespeedtech.com domain to each of the back-end nodes' listeners.

Graceful restart all three LSWS instances.

Verify The Load Balancer

Access the load balancer server (load.litespeedtech.com) to verify everything is working as expected.

You should see that it balances the load between back1 and back2.