>> Deploy
Use Nginx to host FlowCore 3.0 on Linux
important
FlowCore 3.0 built with .NET 8.0/ASP.NET Core 8.0.FlowCore includes a .NET cross-platform Kestrel web server, which can be used alone or with a reverse proxy server.
The FlowCore application <runroot> folder contains the ASP.NET Core directory structure.
FlowCore is launched on Linux from the <runroot/FlowCore.dll> file.
This article demonstrates the use of Ubuntu 20.04 (LTS).
FlowCore 3.0 fully supports Linux distributions supported by ASP.NET Core 8.0.
Check out the list: ASP.NET Linux distributions supported by Core 6.0.
FlowCore 3.0 fully supports Linux distributions supported by ASP.NET Core 8.0.
Check out the list: ASP.NET Linux distributions supported by Core 6.0.
how to install ASP.NET Core 8.0 on Linux
Depending on the Linux distribution you are using, please refer to the official Microsoft documentation to execute the installation command.install the .NET SDK or .NET runtime on Ubuntu
(1)Configure the Kestrel web server.
1.1 Configure Kestrel binding native ports.
Open the </runroot/appsettings.json> you can see that Kestrel binds the local address and port by default <localhost:5000>.
localhost equals 127.0.0.1 and uses Kestrel to bind native addresses and ports, which can be used with reverse proxies (Nginx, Apache).
You can customize the port that Kestrel binds (recommended port range 5000-60000) as long as the port is not occupied.
1.2 Verify that Kestrel is working correctly.
Start the Kestrel web server in the Linux commands line.
Test HTTP access to the Kestrel web server.
1.3 Configure the Linux background service<flowcore.service>.
Use <vim > edit <flowcore.service> and change the deployment path </flowcore> to the actual deployment path.
1.4 Start the service <flowcore.service>.
Install the service
Start the service
Stop the service
View service status
Open the </runroot/appsettings.json> you can see that Kestrel binds the local address and port by default <localhost:5000>.
localhost equals 127.0.0.1 and uses Kestrel to bind native addresses and ports, which can be used with reverse proxies (Nginx, Apache).
You can customize the port that Kestrel binds (recommended port range 5000-60000) as long as the port is not occupied.
"Kestrel": { "Endpoints": { "Http": { "Url": "http://localhost:5000" } } }
1.2 Verify that Kestrel is working correctly.
Start the Kestrel web server in the Linux commands line.
Linux commands
sudo dotnet /flowcore/runroot/FlowCore.dll
Test HTTP access to the Kestrel web server.
Linux commands
curl http://localhost:5000
1.3 Configure the Linux background service<flowcore.service>.
Systemd is a Linux system tool that starts daemons and has become standard on most Linux distributions.
Copy <runroot/flowcore.service> to </etc/systemd/system>.
Linux commands
sudo cp /flowcore/runroot/flowcore.service /etc/systemd/system
Use <vim > edit <flowcore.service> and change the deployment path </flowcore> to the actual deployment path.
Linux commands
flowcore.service
sudo vim /flowcore/runroot/flowcore.service
[Unit] Description=FlowCore [Service] WorkingDirectory=/flowcore/runroot ExecStart=/usr/bin/dotnet /flowcore/runroot/FlowCore.dll Restart=always RestartSec=10 SyslogIdentifier=flowcore User=root Environment=DOTNET_ROOT=/usr/lib64/dotnet TimeoutStopSec=30 [Install] WantedBy=multi-user.target
1.4 Start the service <flowcore.service>.
Install the service
Linux commands
sudo systemctl enable /etc/systemd/system/flowcore.service
Start the service
Linux commands
sudo systemctl start flowcore
Stop the service
Linux commands
sudo systemctl stop flowcore
View service status
Linux commands
sudo systemctl status flowcore
(2)Install Nginx
Install Nginx
View the Nginx service status
Linux commands
sudo apt update sudo apt install nginx
First boot Nginx
sudo service nginx start
Start Nginx
sudo systemctl start nginx
Reboot Nginx
sudo systemctl restart nginx
Stop Nginx
sudo systemctl stop nginx
View the Nginx service status
Linux commands
sudo systemctl status nginx
(3) Configure the NGINX reverse proxy
3.1 Configure the Nginx reverse proxy to forward external HTTP requests to Kestrel.
Edit the nginx configuration file </etc/nginx/sites-available/default> using <vim>.
In the following configuration, Nginx forwards the matching request to the Kestrel listening address <http://127.0.0.1:5000>.
Edit the nginx configuration file </etc/nginx/sites-available/default> using <vim>.
using vim edit the nginx configuration file
sudo vim /etc/nginx/sites-available/default
In the following configuration, Nginx forwards the matching request to the Kestrel listening address <http://127.0.0.1:5000>.
server { listen 80; listen 443 ssl; ssl_certificate /etc/nginx/office.paicore.com.crt; ssl_certificate_key /etc/nginx/office.paicore.com.key; server_name office.paicore.com; location / { proxy_pass http://127.0.0.1:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
3.2 Configure Nginx file upload limits.
Nginx supports uploading files up to 1M by default.
Use <vim > to open </etc/nginx/nginx.conf> and add the following code.
Please configure the file upload limit according to your actual needs.
Nginx supports uploading files up to 1M by default.
Use <vim > to open </etc/nginx/nginx.conf> and add the following code.
Please configure the file upload limit according to your actual needs.
http { client_max_body_size 200M; } server { client_max_body_size 200M; }