Install ASP.Net Core 3 using nginx on Ubuntu 18.04

Finally after 2 days i have been working with this installation. Finally i am completed install Asp.Net Core 3.0 using Nginx as web server then deploy it of one my project on github project .

Actually that project taken from other github but currently still using Core 2. Becaus i am installed Asp.Net Core 3.0, I decide to modify some code then i published to my github so i able to download from my ubuntu server and deploy it.

Since i already installed Nginx and you can see on this article So i will skip the step to install Nginx.

Here are the steps as follow :

1.Apt-get update

Before installing new software, it is strongly recommended to update your local software database. Updating helps to make sure you’re installing the latest and best-patched software available.

sudo apt-get update

2. Install the Prerequisites

wget -q sudo dpkg -i packages-microsoft-prod.deb

Install the .NET SDK

sudo apt-get install apt-transport-https 
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

To confirm your installation and to check the version of dotnet cli installed on the machine type the following command. You should get an output

dotnet —-version

Output :

root@sandbox01:~# dotnet –version

3.Define Server Blocks for Port 3100

Since my port 80, 2100 already used with other application. I decided to create one application using 3100

Here the syntax :

sudo mkdir /etc/nginx/sites-available/netmoviesapps

Paste in the following configuration block, which is similar to the default, but updated for our new directory and domain name:

server {
listen 3100;
location / {
   proxy_pass http://localhost:5000;
   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection keep-alive;
   proxy_set_header Host $http_host;
   proxy_cache_bypass $http_upgrade;

sudo ln -s /etc/nginx/sites-available/netmoviesapps /etc/nginx/sites-enabled/

4. Create a web  Movie List

Create the directory for html_2100 as follows, using the -p flag to create any necessary parent directories:

sudo mkdir -p -p /var/www/movie-app

Next, assign ownership of the directory with the $USER environment variable:

sudo chown -R $USER:$USER /var/www/movie-app

The permissions of your web roots should be correct if you haven’t modified your umask value, but you can make sure by typing:

sudo chmod -R 755 /var/www/movie-app

Now, you can move into the parent directory and clone the application on GitHub:

cd /var/www
git clone

Now, to build the project and all its dependencies, run the following command:

cd /var/www/movie-app dotnet build dotnet publish

5. Setting Kestrel process

Kestrel is an open source, cross platform, light weight and a default webserver used for Asp.Net Core applications. Asp.Net Core applications run Kestrel webserver as in-process server to handle web request. Kestrel is cross platform, runs in Windows, LINUX and Mac. Kestrel webserver supports SSL.  To handle this and ensure that the Kestrel process keeps running in the background, you will use systemd functionalities.

Systemd files will allow you to manage a process by providing start, stop, restart, and log functionalities once you create a process of work called a unit.

Move into the systemd directory:

cd /etc/systemd/system

Create a new file for editing:

sudo nano movie.service

Description=Movie app

ExecStart=/usr/bin/dotnet /var/www/movie-app/bin/Debug/netcoreapp3.1/publish/MovieListCore3.dll


Now save the file and enable the new movie service created with:

sudo systemctl enable movie.service

After that, proceed to start the service and verify that it’s running by starting the service:

sudo systemctl start movie.service

Then check its status:

sudo systemctl status movie.service
sudo nginx -s reload


Here the screenshot, after all the deployment above completed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.