Configuring the Nginx server

Configure the Nginx server by modifying the file (/etc/nginx/sites-available/default) to have the following content—so that Nginx will forward the request to ASP.NET. In order to modify this file, you need to have sufficient rights—try switching to a super user. The  Sudo su is the command for switching it to a super user. See the following code:

server {
  listen 80;
  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 $host;
    proxy_cache_bypass $http_upgrade;
  }
}

The code looks like the following:

Configuring the Nginx server

Run the application by executing the following command:

dotnet run

You will see the following screen:

Configuring the Nginx server

Now access the application from your browser using the public DNS (AWS created the public DNS when the instance was launched):

Configuring the Nginx server

Voila! We have created the ASP.NET Core web application and launched it in the Linux box. We have even used the cloud through Amazon Web Services (AWS).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset