Configure OpenLiteSpeed load balancing with multiple backend servers

Intermediate 45 min Apr 27, 2026 102 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Set up OpenLiteSpeed as a reverse proxy and load balancer to distribute traffic across multiple backend application servers with health checks and automatic failover for high availability.

Prerequisites

  • Root or sudo access
  • Multiple servers for backend pool
  • Basic understanding of web servers
  • Network connectivity between servers

What this solves

OpenLiteSpeed load balancing distributes incoming web traffic across multiple backend servers to prevent overload and ensure high availability. This configuration provides automatic failover when backend servers become unavailable and improves application performance through intelligent traffic distribution.

Step-by-step configuration

Update system packages

Start by updating your package manager to ensure you get the latest versions of all components.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install OpenLiteSpeed

Download and install the OpenLiteSpeed web server from the official repository to get the latest stable version.

wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | sudo bash
sudo apt update
sudo apt install -y openlitespeed
sudo rpm -Uvh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el8.noarch.rpm
sudo dnf install -y openlitespeed

Set OpenLiteSpeed admin password

Create an administrative user account for accessing the OpenLiteSpeed web administration interface.

sudo /usr/local/lsws/admin/misc/admpass.sh

Enter a username and secure password when prompted. This account will be used to access the web admin panel.

Start and enable OpenLiteSpeed

Start the OpenLiteSpeed service and configure it to start automatically on system boot.

sudo systemctl start lsws
sudo systemctl enable lsws
sudo systemctl status lsws

Configure firewall access

Open the required ports for OpenLiteSpeed web server (8088 for admin, 80/443 for web traffic).

sudo ufw allow 8088/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw --force enable
sudo firewall-cmd --permanent --add-port=8088/tcp
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --reload

Access the OpenLiteSpeed admin panel

Navigate to the web administration interface to configure load balancing settings.

https://your-server-ip:7080

Use the username and password you created in the previous step to log in. Accept the SSL certificate warning if prompted.

Set up backend application servers

Install and configure simple web applications on your backend servers for testing the load balancer.

# On each backend server (192.168.1.10, 192.168.1.11, 192.168.1.12)
sudo apt update
sudo apt install -y nginx
sudo systemctl start nginx
sudo systemctl enable nginx

Create unique content for each backend

Add distinct content to each backend server to verify load balancing is working correctly.

echo "

Backend Server 1

IP: 192.168.1.10

" | sudo tee /var/www/html/index.html
echo "

Backend Server 2

IP: 192.168.1.11

" | sudo tee /var/www/html/index.html
echo "

Backend Server 3

IP: 192.168.1.12

" | sudo tee /var/www/html/index.html

Create load balancing cluster in OpenLiteSpeed

In the admin panel, navigate to Load Balancer → Clusters and click the "+" button to add a new cluster.

Configure the cluster with these settings:

  • Type: Load Balancer
  • Name: backend-cluster
  • Mode: Stateless
  • Strategy: Round Robin
  • Session Timeout: 3600

Add backend servers to the cluster

In the backend-cluster configuration, go to the "Workers" tab and add each backend server.

For each backend server, click "+" and configure:

  • Type: Proxy
  • Name: backend1 (backend2, backend3)
  • Address: 192.168.1.10:80 (192.168.1.11:80, 192.168.1.12:80)
  • Max Connections: 100
  • Initial Request Timeout: 60
  • Retry Timeout: 0

Configure health checks

Enable health monitoring for automatic failover when backend servers become unavailable.

In each worker configuration, set the following health check parameters:

  • Enable Health Check: Yes
  • Health Check URL: /
  • Check Period: 30 seconds
  • Grace Period: 30 seconds
  • Hard Limit: 2
  • Soft Limit: 1

Create a virtual host for load balancing

Navigate to Virtual Hosts and create a new virtual host to handle incoming requests.

Configure the virtual host with these settings:

  • Virtual Host Name: load-balancer
  • Document Root: /usr/local/lsws/Example/html/
  • Enable Scripts/ExtApps: Yes

Map the cluster to virtual host

In the virtual host configuration, go to the "Context" tab and create a new context.

Configure the context mapping:

  • Type: Proxy
  • URI: /
  • Web Server: cluster:backend-cluster
  • Accessible: Yes
  • Extra Headers: X-Forwarded-For $remote_addr

Configure listener and virtual host mapping

Navigate to Listeners and ensure the HTTP listener (*:80) is configured and mapped to your virtual host.

In the Listener configuration:

  • IP: *
  • Port: 80
  • Secure: No

Map the virtual host in the "Virtual Host Mappings" tab:

  • Virtual Host: load-balancer
  • Domain: *

Apply configuration changes

Click the "Graceful Restart" button in the admin panel to apply all configuration changes without dropping existing connections.

Monitor the server status to ensure all backends are healthy and responding to requests.

Configure SSL termination

Generate SSL certificate

Create a self-signed SSL certificate for testing, or use Let's Encrypt for production deployments.

sudo mkdir -p /usr/local/lsws/ssl
sudo openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 \
  -keyout /usr/local/lsws/ssl/server.key \
  -out /usr/local/lsws/ssl/server.crt \
  -subj "/C=US/ST=State/L=City/O=Organization/CN=example.com"

Configure HTTPS listener

In the admin panel, create a new HTTPS listener for secure connections.

Navigate to Listeners and add a new listener with these settings:

  • Listener Name: HTTPS
  • IP: *
  • Port: 443
  • Secure: Yes

Configure SSL settings

In the HTTPS listener configuration, go to the "SSL" tab and configure:

  • Private Key File: /usr/local/lsws/ssl/server.key
  • Certificate File: /usr/local/lsws/ssl/server.crt
  • Protocol Version: TLSv1.2 TLSv1.3
  • Ciphers: EECDH+AESGCM:EDH+AESGCM

Map virtual host to HTTPS listener

Add the load-balancer virtual host mapping to the HTTPS listener in the "Virtual Host Mappings" tab.

Configure the mapping:

  • Virtual Host: load-balancer
  • Domain: *

Advanced load balancing configuration

Configure session persistence

Enable sticky sessions to ensure users stay connected to the same backend server throughout their session.

In the cluster configuration, modify these settings:

  • Session Affinity: IP Hash
  • Session Cookie: LBSESSION
  • Cookie Timeout: 3600

Set up weighted load balancing

Assign different weights to backend servers based on their processing capacity.

In each worker configuration, adjust the weight parameter:

  • Backend1 Weight: 3 (high-performance server)
  • Backend2 Weight: 2 (medium-performance server)
  • Backend3 Weight: 1 (lower-performance server)

Configure connection limits

Set appropriate connection limits to prevent backend server overload and ensure optimal performance distribution.

In the cluster configuration, adjust these limits:

  • Max Connections: 500
  • Smart Keep Alive: Yes
  • Keep Alive Timeout: 60
  • Initial Request Timeout: 60

Verify your setup

# Check OpenLiteSpeed service status
sudo systemctl status lsws

Verify listeners are active

sudo netstat -tlnp | grep lshttpd

Test load balancing with multiple requests

for i in {1..6}; do curl -s http://your-server-ip/ | grep "Backend Server"; done

Check SSL configuration

curl -k https://your-server-ip/

Monitor backend server health

tail -f /usr/local/lsws/logs/error.log
Note: You should see requests distributed across different backend servers in the curl output, confirming that load balancing is working correctly.

Monitor load balancer performance

Enable access logging

Configure detailed access logs to monitor traffic patterns and backend server response times.

Use Server's Access Log: No
File Name: /usr/local/lsws/logs/load-balancer.log
Log Format: %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %D
Bytes Log: /usr/local/lsws/logs/load-balancer-bytes.log

Monitor backend server status

Use the real-time report in the admin panel to monitor cluster health and performance metrics.

Navigate to Real-Time Stats → Clusters to view:

  • Active connections per backend server
  • Request distribution statistics
  • Backend server health status
  • Response time metrics

Set up log monitoring

Monitor OpenLiteSpeed logs for health check failures and performance issues.

# Monitor error logs for backend health issues
sudo tail -f /usr/local/lsws/logs/error.log | grep -i "backend\|cluster\|worker"

Monitor access logs for request patterns

sudo tail -f /usr/local/lsws/logs/load-balancer.log

Check backend connection statistics

grep -i "connection" /usr/local/lsws/logs/error.log | tail -10

Common issues

SymptomCauseFix
502 Bad Gateway errorsBackend servers unreachableCheck backend server status and firewall rules: curl http://backend-ip
Requests not load balancedCluster mapping incorrectVerify context mapping in virtual host points to cluster:backend-cluster
SSL certificate warningsSelf-signed certificateUse proper CA-signed certificate or configure browsers to accept self-signed
Health checks failingIncorrect health check URLVerify health check URL exists on backend servers: curl http://backend-ip/
Admin panel inaccessibleFirewall blocking port 7080Open admin port: sudo ufw allow 7080/tcp
Session persistence not workingIP Hash not configuredSet Session Affinity to "IP Hash" in cluster configuration
High response timesBackend server overloadAdd more backend servers or adjust connection limits and weights
Configuration changes not appliedServer not restartedClick "Graceful Restart" in admin panel after configuration changes

Performance optimization

Tune worker processes

Optimize OpenLiteSpeed worker processes for your server's CPU cores and expected traffic load.

In Server Configuration → General, adjust:

  • Number of Workers: CPU cores + 1
  • Worker Group User: nobody
  • Worker Group: nogroup
  • Max Connections: 2000

Configure caching

Enable caching to reduce backend server load and improve response times.

In Virtual Host → Cache, configure:

  • Enable Cache: Yes
  • Cache Root: /usr/local/lsws/cache
  • Cache Policy: Public cache for static files
  • Expire Time: 86400 (24 hours)

Enable compression

Configure GZIP compression to reduce bandwidth usage and improve page load times.

In Virtual Host → General → Enable Compression:

  • Enable Compression: Yes
  • GZIP Compression Level: 6
  • Compressible Types: text/*, application/javascript, application/json

Next steps

Running this in production?

Want this handled for you? Setting up OpenLiteSpeed load balancing once is straightforward. Keeping it patched, monitored, backed up and tuned across environments is the harder part. See how we run infrastructure like this for European SaaS and e-commerce teams.

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

We handle managed cloud infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.