ASP.net

#1
Hi Everyone,

The last 2 weeks I have been testing and evaluating the LiteSpeed webserver, in the search if this webserver is the webserver for our company.

However I need to run ASP.net applications on this webserver aswell. Do you have any guides that will work with Ubuntu/LSWS.

I found several ways ASP.net Core and the Mono project, however there are no clear or complete guides that will help me get the last few puzzle pieces in place.

Could anyone here be of help to me?

Kind Regards,

Daniël
 
#3
Steps to run a dotnet project (Website.dll) on CyberPanel and OpenLiteSpeed on a domain: yourdomain.com

Make sure CyberPanel, OpenLiteSpeed and dotnet core 5.0 is installed on the server and SSL is issued for yourdomain.com

--------------------------------------------------------------------

Following code should already be added to Website.dll as described in: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-5.0

app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});

app.UseAuthentication();

--------------------------------------------------------------------

Step 1. Publish the dotnet project in the folder:

/home/yourdomain.com/public_html/

--------------------------------------------------------------------

3. If Website.dll uses database, then make sure you have set the same user and password in your database in CyberPanel:

Change user password in CyberPanel -> Databases -> PhpmyAdmin -> "User Accounts" -> Change Password

--------------------------------------------------------------------

2. Make dotnet Website.dll a service:

Create a service file:

sudo nano /etc/systemd/system/website.service

File contents:

[Unit]
Description=Example .NET Web App running on Ubuntu

[Service]
WorkingDirectory=/home/yourdomain.com/public_html
ExecStart=/usr/bin/dotnet /home/yourdomain.com/public_html/Website.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

--------------------------------------------------------------------

4. Enable the service:

sudo systemctl enable website.service
sudo systemctl daemon-reload
sudo systemctl start website.service

--------------------------------------------------------------------

5. Check if the service is listening to 5000 port using:

sudo systemctl status website.service

--------------------------------------------------------------------

6. Now, the dotnet assembly should be running fine on 5000 port:

localhost:5000

you can check it on Firefox or using curl command

--------------------------------------------------------------------

7. Setup dotnet server in OpenLiteSpeed:

Server Configuration -> External App -> Click "+" button -> Type: Web Server -> Click ">|" button on right side -> Name: dotnet_website -> Address: localhost:5000 -> Max Connections: 1900 -> Initial Request Timeout (secs): 5 -> Retry Timeout (secs) -> 5

8. Perform graceful restart of OpenLiteSpeed at top-right Reset button.

9. "Virtual Hosts" -> yourdomain.com -> Context -> Click "+" button -> Type: Proxy -> Click ">|" button on right side -> Enter URI as a slash (root): / -> Click save button on right side

10. Perform graceful restart of OpenLiteSpeed at top-right Reset button.
 
Top