Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  Web Hosting  >  How to Configure a Node.js Application with OpenLiteSpeed?

How to Configure a Node.js Application with OpenLiteSpeed?

 3 min

Configuring a Node.js application behind OpenLiteSpeed combines Node’s high-performance event loop with OpenLiteSpeed’s ultra-fast HTTP handling, built-in caching, and low memory footprint. OpenLiteSpeed acts as a reverse proxy through its built-in App Server context, managing the Node process directly while handling SSL termination and static file delivery.

1. Create a Virtual Host

Log in to the OpenLiteSpeed WebAdmin Panel using your username and password.

Go to Virtual Hosts → Add and enter the required details as shown in the screenshots. You can set the Virtual Host name as per your requirement.

Screenshot_1
Screenshot_2

In the Config File section, enter:

$SERVER_ROOT/conf/vhosts/myapp/vhconf.conf

Replace myapp with your Virtual Host name.

Screenshot_3
Screenshot_4

Click Save after entering the required details.

2. Configure the Virtual Host Document Root

Go to Virtual Hosts → myapp → General → Edit.

In the Document Root section, enter:

$VH_ROOT

Click Save.

Screenshot_5

3. Configure the External Application

Go to Virtual Hosts → myapp → External App → Add.

Select Web Server (Proxy) and click Next.

Enter the required details as shown in the screenshot and click Save.

Screenshot_6

4. Configure the Proxy Context

Go to Virtual Hosts → myapp → Context → Add.

Select Proxy and click Next.

Enter the required details as shown in the screenshot and click Save.

Screenshot_7

5. Configure the HTTP Listener

Go to Listeners → Default → Edit → General → Virtual Hosts Mappings → Add.

Enter the required details as shown in the screenshot and click Save.

Screenshot_8

6. Configure the HTTPS Listener

Repeat the same Virtual Host Mapping configuration for the HTTPS listener.

Once the configuration is completed, click Graceful Restart.

Screenshot_9

7. Install SSL on the Domain

Run the following command and replace yourdomain.com with your actual domain:

certbot certonly --standalone -d yourdomain.com --pre-hook "systemctl stop lsws" --post-hook "systemctl start lsws"

Example:

certbot certonly --standalone -d recipe.thatisfun.in --pre-hook "systemctl stop lsws" --post-hook "systemctl start lsws"

Once the SSL certificate is installed, Certbot will display the paths of the SSL certificate and private key.

8. Configure SSL in OpenLiteSpeed

Go to Listeners → HTTPS → SSL → Edit.

Enter the SSL certificate and private key paths provided by Certbot in the respective fields and click Save.

Screenshot_10

9. Restart OpenLiteSpeed

Click Graceful Restart in the OpenLiteSpeed WebAdmin Panel.

Alternatively, restart the service using:

systemctl restart lsws

Your Node.js application is now ready to use with OpenLiteSpeed.

The Closing Line

By leveraging OpenLiteSpeed as a frontend server for Node.js, your application benefits from reduced resource consumption, automatic SSL handling, and integrated page caching without complex external process managers like PM2. This setup provides a reliable, enterprise-ready environment capable of handling high-traffic Node applications efficiently.

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.