.Net Core 3.1 Deploy on Centos 7

.Net Core 3.1 deploy on Centos 7

I solved the problem.
When we create a domain in the plesk panel, apache creates its own configuration file, so all I have to do is change the Additional apache directives settings from within Apache & nginx under the Hosting & DNS settings of the relevant domain from the plesk panel.

Plesk --> Websites & Domains --> <> --> Hosting & DNS --> Apache & nginx

Additional directives for HTTP

Header set Access-Control-Allow-Origin "http://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/

Additional directives for HTTPS

Header set Access-Control-Allow-Origin "https://yourdomain.com"
Header set Access-Control-Allow-Headers "Access-Control-Allow-Headers, Origin, Accept,
X-Requested-With, Content-Type, Access-Control-Request-Method, Access-ControlRequest-Headers, Authorization, Content-Disposition"
Header set Access-Control-Allow-Methods "*"
Header set Access-Control-Allow-Credentials "true"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:5000/
ProxyPassReverse / http://127.0.0.1:5000/

If you have a cors problem, you can add lines starting with header set.

After doing all these, your application will run if it is ready in your service file.

How to run a .NET Core console application on Linux

Follow the below steps to run your application:

  1. Publish your application as a self contained application:

    dotnet publish -c release -r ubuntu.16.04-x64 --self-contained
  2. Copy the publish folder to the Ubuntu machine

  3. Open the Ubuntu machine terminal (CLI) and go to the project directory

  4. Provide execute permissions:

    chmod 777 ./appname
  5. Execute the application

    ./appname

How to compile .NET Core app for Linux on a Windows machine

Using dotnet build command, you may specify --runtime flag

-r|--runtime < RUNTIME_IDENTIFIER >

Target runtime to build for. For a list of Runtime Identifiers (RIDs) you can use, see the RID catalog.

RIDs that represent concrete operating systems usually follow this pattern [os].[version]-[arch]

Fo example, to build a project and its dependencies for Ubuntu 16.04 runtime use:

dotnet build --runtime ubuntu.16.04-x64

.NET Core 3.1 Kestrel/Apache stop responding requests

My problem was was simpler than I thought, just had to increase the MaxRequestWorkers in /etc/apache2/mods-available/mpm_event.conf, as SignalR mainly uses WebSocket connections which keeps a request worker busy as long as it is connected.

Another possible solution was to change the HttpTransportType in the client and force another type, as ServerSentEvents for example, but it has other counterparts.



Related Topics



Leave a reply



Submit