[How-To] Reverse proxy OpenLiteSpeed on DirectAdmin (working with NET Core - Blazor)

pallinarozza

Verified User
Joined
Dec 21, 2019
Messages
5
Hi at all,
Yesterday I was trying to add reverse proxy on OpenLiteSpeed for my NET Core application, but there was no guide for DirectAdmin. Today I just figured out how to do it.
This guide will cover only the setup part on DirectAdmin.
My net core app runs at 127.0.0.1:5000
  1. First at all login on your DirectAdmin dashboard.
  2. Go in Custom HTTPD Configurations.
  3. Click on openlitespeed.conf on your domain line.
  4. Click on Customize
  5. Click on CUSTOM2(Appears in scripthandler{} section. ) and paste this:
    Code:
    add proxy:Backend html
  6. Click on CUSTOM5(Appears in rewrite{} section. ) and paste this:
    Code:
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
    RewriteRule /(.*) ws://127.0.0.1:5000/$1 [P]
  7. Click on CUSTOM7(Appears at the end of the virtualHost.) and paste this:
    Code:
    extprocessor Backend{
    type proxy
    address 127.0.0.1:5000
    maxConns 2000
    initTimeout 20
    retryTimeout 0
    respBuffer 0
    }
    
    context / {
    type proxy
    handler Backend
    addDefaultCharset off
    }

    You can configure "maxConns", "initTimeout", "retryTimeout" and "respBuffer" parameters or copy and paste this. At the end of the post you can find some info about these parameters.

  8. Click on SAVE (if you see some error like "log file is not writable" or "failed to set up error log!" or " failed to set up access log!" you can ignore them.
  9. Click on BACK and click again on BACK
  10. Click on ./build rewrite_confs
  11. Finish. Start your webApp and you will see your website showing the webApp

Usefull info about the configuration (taken from OpenLiteSpeed console):
maxConns - Max Connections : (Number valid range: 1 - 2000)
Specifies the maximum number of concurrent connections that can be established between the server and an external application. This setting controls how many requests can be processed concurrently by an external application, however, the real limit also depends on the external application itself. Setting this value higher will not help if the external application is not fast enough or cannot scale to a large number of concurrent requests.

Tip(s):
  • Setting a high value does not directly translate to higher performance. Setting the limit to a value that will not overload the external application will provide the best performance/throughput.

initTimeout - Initial Request Timeout (secs) : Number valid range >= 1
Specifies the maximum time in seconds the server will wait for the external application to respond to the first request over a new established connection. If the server does not receive any data from the external application within this timeout limit, it will mark this connection as bad. This helps to identify communication problems with external applications as quickly as possible. If some requests take longer to process, increase this limit to avoid 503 error messages.

retryTimeout - Retry Timeout (secs): Number valid range >= 0
Specifies the period of time that the server waits before retrying an external application that had a prior communication problem.

respBuffer - Response Buffering: Numbers valid: 0 or 1 or 2
Specifies whether to buffer responses received from external applications. If a "nph-" (Non-Parsed-Header) script is detected, buffering is turned off for responses with full HTTP headers.
Values:
  • 0 : No
  • 1 : Yes
  • 2 : No for Non-Parsed-Header (NPH)
 
Last edited:
Server 500 Error happening. What could be the reason? SSL installed and 127.0.0.1:5000 app is up and running smoothly. not working??

sudo systemctl status baabilink.service
● baabilink.service - BaabiLink Web App running
Loaded: loaded (/etc/systemd/system/baabilink.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-04-24 13:56:15 +03; 2h 9min ago
Main PID: 877 (dotnet)
CGroup: /system.slice/baabilink.service
└─877 /usr/bin/dotnet /home/admin/domains/baabi.link/public_html/B...
 
Back
Top