# Litespeed Configuration Guide

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* LiteSpeed Web Server (OpenLiteSpeed or LiteSpeed Enterprise) installed and running
* Admin access to LiteSpeed WebAdmin Console
* A domain configured on a Virtual Host (e.g., litespeed.jtm-demo.com) with DNS pointing to your server

### Step 1: Create an External App (Web Server) <a href="#step-1-create-an-external-app-web-server" id="step-1-create-an-external-app-web-server"></a>

Navigate to your Virtual Host, then open the **External App** tab and add a new Web Server definition with the following settings:

| **Field (Web Server Definition**) | **Example Value**      | **Notes**                                                        |
| --------------------------------- | ---------------------- | ---------------------------------------------------------------- |
| Name                              | hash\_proxy            | Descriptive identifier referenced by rewrite rules               |
| Address                           | <https://hash.url.com> | Full URL of backend (HTTP or HTTPS). Match your upstream scheme. |
| Max Connections                   | 100                    | Range 1–2000. Tune based on backend capacity.                    |
| Connection Keepalive Timeout      | 60                     | Use persistent connections to improve performance; -1 disables.  |
| Initial Request Timeout (secs)    | 60                     | Must be >= 1. Increase for slow upstreams.                       |
| Retry Timeout (secs)              | 1                      | Backoff window before retrying failed connections.               |
| Response Buffering                | No                     | Disable for streaming/low-latency responses.                     |

Optionally set Environment variables and Notes as needed using PROPERTY=VALUE syntax.

If your backend uses HTTPS with a certificate that is self-signed or not publicly trusted, ensure your LiteSpeed build trusts the upstream or use HTTP to the backend within a private network.

### Step 2: Enable and Add Rewrite Rules <a href="#step-2-enable-and-add-rewrite-rules" id="step-2-enable-and-add-rewrite-rules"></a>

Within the same Virtual Host, open the **Rewrite** tab.

1. In Rewrite Control, set Enable Rewrite to Yes. Optionally adjust Log Level.
2. In Rewrite Rules, click Edit and paste the following rules, then Save:
3. Gracefully restart LiteSpeed to apply the changes (Actions > Graceful Restart).

{% hint style="info" %}
Please make sure to replace the values "hash" and "url.com" with your values from the DCP configuration page
{% endhint %}

```
RewriteEngine On 
# The E=proxy-host part forces the correct Host header to the backend 
RewriteRule ^/?hash(/.*)?$ http://hash_proxy/$1 [P,L,QSA,E=proxy-host:hash.url.com]
```

### Result

Requests to /kndmjf on your domain will be proxied to the external app defined as kndmjf\_proxy, preserving query strings and forwarding the correct Host header to the upstream.
