Hosting ASP.NET Core 2.0 Web Api on Azure Ubuntu Server with Nginx and Mutual SSL Authentication (PART 1)
PART 1: Deploying Azure Ubuntu Server
In this post series, I will step by step show you how to host a ASP.NET Core 2.0 Web Api which is using mutual SSL authentication on a Azure Ubuntu Server using Nginx as the reverse proxy server and Kestrel as the default application server.
In this part we will see how to ceploy an Ubuntu Linux server in Azure cloud.
For information about how to setup .Net Core SDK 2.0 and Nginx on Ubuntu Linux check part-2 of this series.
For information about how to configure Azure Network Security Group and Publishing Asp.Net Core Web Api check part-3 of this series.
For information about how to setup a service to manage kestrel process, creating self-signed SSL certificate and configuring Nginx as a reverse proxy server check part-4 of this series.
For information about how to setup mutual SSL for client authentication and passing client certificate data to Asp.Net Core Web Api using HTTP headers check part-5 of this series.
Create a virtual machine
Login to your Azure portal. (For this you need a windows account and a subscription)
Click on “Virtual Machines (classic)” and “Add” button.
Select “Ubuntu Server” from marketplace.
Select Ubuntu Server version. (In this case “Ubuntu Server 17.04”)
Choose “Resource Manager” as the deployment model and press “Create” button.
Fill the basic settings configuration, select a virtual machine size (for testing I chose B2 Standart) and other data.
I chose “Password” as the “Authentication type” which is less secure but easier for me to use. (Note: When you choose password as the authentication type Azure requires a looong and comprehensive password!)
Finally, review your configuration and if you are fine with it let Azure start your new Ubuntu instance.
Connecting virtual machine
I use Putty (an SSH and telnet client) to connect and manage my Ubuntu server from Windows development machine.
In your virtual machine overview screen you can create a DNS name for your server. It is important because once your instance is stopped your public IP address changes (unless you configure it not to do so [which costs extra]) and you have to use the new IP address for connecting, accessing your web api etc.
In the “Session” category of Putty:
I assume you’ve created a DNS name for your server. Write that on the “Host name” field.
Select “SSH” as the “Connection Type”.
In the “Connection > Data” category of Putty:
Write your server user name to the “Auto-login username” field.
You can also make some configuration changes for Window appearance etc. and save them in the “Saved Sessions” category.
Once you are with the Putty configuration click on “Open” button and start your SSH connection.
Port 22 is the default port for SSH connections and for that reason in Azure resource group firewall this port is already allowed. Your connection will fail if it is not the case in your configuration.
Moreover, Azure created Ubuntu Server’s firewall is off as default. This means all the port management can be done in Azure portal.
To manage inbound and outbound ports click on the “Networking” category in your Azure instance management page. (We will use this section later to allow web traffic of our web api!)
Series will continue with configuring Ubuntu server for .Net Core hosting.
Hope it helps!
Originally published at https://www.weboideas.com on November 23, 2017.