After we successfully installed and configured XFCE on Ubuntu 14.04 and ASP.NET Core 1.0 in part 1 of this tutorial, we have to add NGINX to expose our great Hello World app to the internet. As I mentioned in part I, it’s not advisable to expose Kestrel directly, since it’s not meant to be used like that and has lot of limitation as a front-end web server: handling of multiple host names, authentication, HTTPS offloading, caching, just to mention few.

Nginx will receive requests for specific host name (we’ll point subdomain or domain to our Azure VM) and route them to internal Kestrel URL (localhost:5000 in this example). This configuration is called Reverse Proxy. Same thing can be done also with IIS Application Request and Routing module on Windows.

Point DNS to Azure VM

Let’s start with updating our DNS records. Open your DNS provider-of-choice and add CNAME record that points to Azure VM DNS name. Azure usually creates name like myvmname.westeurope.cloudapp.azure.com. Here, I created subdomain on this blog domain: http://coretest.hudosvibe.net


If you don’t want to update DNS records, then just edit you OS hosts file and point subdomain.domain.com to IP address of this Azure server!

NGINX installation

SSH into your VM or RDP into XFCE, and open bash. To install nginx type:

sudo apt-get update
sudo apt-get install nginx

If you open your browser and type Azure DNS name or subdomain into address bar, nginx welcome page should open! From within VM, you can try to open (with Midori) http://localhost, the same welcome page should open (the same web opened from my dev machine and from Ubuntu with Midori): 



NGINX Reverse proxy to Kestrel server configuration

Open your favorite editor (nano, geany) as sudo, create a new file with the content (again, change sub/domain name):

server {
    listen 80;
    listen [::]:80;

    server_name subdomain.domain.com;

    location / {
        proxy_pass http://localhost:5000;

This will forward all requests to internal Kestrel web server that’s listening on the port 5000 (it’s started with dotnet run, right?).

Save the file as /etc/nginx/sites-available/subdomain.domain.com

We have to enable this website, and that’s done by creating a link to that file in /etc/nginx/sites-enabled:

sudo ln -s /etc/nginx/sites-available/subdomain.domain.com /etc/nginx/sites-enabled/

Now open nginx configuration file

sudo nano /etc/nginx/nginx.conf, or
sudo geany /etc/nginx/nginx.conf

find and uncomment this line: server_names_hash_bucket_size 64;

After restarting nginx this reverse proxy configuration should work:

sudo service nginx restart


More details on nginx configuration can be found here, and about reverse proxy please visit this link.



Here are few tips how to create and run ASP.NET Core application under Linux (Ubuntu 14.04 LTS), on a cheap Azure VM (0.75GB RAM, 0.25 CPU cores). Windows Server requires a little bit more memory (way around that is to increase the size while you're configuring the machine, and then lower it while not working in RDP).

Goals of this exercise are:

  • Cheap Azure VM with Linux (around 10-15$/month). There are other hosting option, for example on Hetzner, for ~5€/m

  • RDP protocol, not VNC (VNC uses Jpegs to transfer screen updates, that's very slow compared to RDP protocol)

  • Some graphical UI that's not standard Ubuntu Gnome (to save memory) for basic text editing task (since I'm still struggling with linux bash text editors and copy-paste between them)

  • Dot Net Core installed, ASP.NET Core app

  • NGINX in front of kestrel, to serve as a Reverse Proxy(similar to Application Request Routing on IIS)

Luckily, there's a great blog post on how to install UI on top of Ubuntu Server, and uses XFCE:


TIP: to use bash and ssh from windows, there are few options: new native Bash on Win10, Git bash, or putty. They all have ssh.
Open bash and type this to ssh into new linux vm: ssh -l username IP/DNS name 

So please, go ahead, follow those simple steps, I'll wait here.

If you're running Azure VM, firewall needs to be configured for RDP:
open VM blade, Settings, Network Interface, Settings, Network Security Group, Settings, Inbound Security Rules. There, add rule for destination port 3389.

Also, it's useful to assign DNS name to that machine, to avoid using dynamic IP address.

You should be able to RDP into the machine now! First time I got some error with "connection error", but I tried again immediately, and was able to RDP and log in into XFCE.

We can now install two apps:

  • Midori web browser (open terminal, type sudo apt-get install midori)

  • Geany text editor (in terminal type sudo apt-get install geany. It will be installed under /usr/bin folder. If you navigate there with file browser, you can right click to it and choose Send To/Desktop Create Link). Btw, don’t expect code completion, it's just syntax highlighting. And if you feel brave enough, there’s always VIM. Purpose of installing text editor is not to develop an app on web server, but just to edit configuration files!

Now we should able to open Midori and page https://www.microsoft.com/net/core#ubuntu, and follow steps to install dotnet core. Needless to say, that worked fine for me:)

To create new asp.net app, follow this: https://aspnet-aspnet.readthedocs-hosted.com/en/latest/getting-started.html . Geany text editor can be used now to edit project.json and CS files (or Nano from bash). Check for namespaces when copy-pasting from tutorial, it's probably different from the one created by dotnet new.

Executing dotnet run will start Kestel, and sample page can be opened in Midori! Happy days!

XFCE running with Midori, Kestrel, Geany takes around 70% of 0.75GB RAM, which is OK for playing with new dotnet and even running small-medium websites in production.  

Next blog post will explain how to put Nginx in front of kestrel, since that's recommended production configuration (that's how node and other platforms are exposed to internet, there is always some reverse proxy in front of platform web server – kestrel doesn't know how to cache, authenticate request, handle https, etc)


For the last year or even more I've been waiting for "usable" build, beta, release candidate, whatever, of the new Core .NET framework and tooling support.  I played with RC1 and betas before, but always had so much trouble in configuring everything, from configuration of project file to producing DLLs and nugets. Specially figuring out various target framework names and standards (dnxcore, net standard, etc – that’s still a mystery too me mostly!). 

Also, lot of things have changed along the way. Since whole development process is so public now, we can see all the changes, mistakes, proof of concepts, some more changes, which were happening behind closed door before where we would just get final RTM bits. So there's that price we as community had to pay, going from DNX and DNU to CLI,   project.json going away soon, who knows what else ...

But I guess, important thing is that framework bits are stable and ready for production use! Runtime, web server (Kestrel, RIP Helios btw), MVC and WebAPI are good to start serious development. Also, Visual Studio for RC2 works fine, which is absolutely necessary for any serious work. 

Lot of blog posts have been written on this topic already, but I would like to point few things which are important now, for us, normal developers working in some company:

  • whole new platform to learn & explore: we can now develop on Mac, host on Linux, even run Sql Server on linux! I would say it's a big and important change, going from (not always so) easy-to-use point'n'click server interface to bash command line. It's so serious thing that even Win 10 includes full bash support now!
  • new tools available on linux: things like nginx, haproxy, which are mandatory for ASP.NET on linux - you shouldn't expose Kestrel to public! Then different databases, from awesome PostgreSql (my bets are on that one, combined with Marten for NoSql story), Redis, Cassandra, and list goes on ... We have to switch from "IIS application server" mindset to docker style of deployment, with chef and puppet0 for configuration management. That leads naturally to bunch of small services instead of few monolithic one, and that involves service discovery tools like zookeeper and consul.
  • To be honest, as a .NET dev I was really jealous on all linux-platform devs for last few (10?) years! They had docker, bunch of fancy data stores, mezos, big data tools, bunch of analytics and logging tools (Kibana, Kubernetes) ... while we (windows server centric) developers where totally isolated, there's whole brave new world of tools, frameworks and services emerging and we're still fighting with MsBuild and MsDeploy and Sql Server. I will not even mention MSMQ here. I don't want to find myself in "who moved my cheese" position, and it looks I'm awfully close.
  • actors. Really important concept, not the silver bullet for every use case, but it has it's place. Microsoft is pushing that also with Azure Service Fabric, with statefull and stateless variants of actors and services. Akka in JVM (java and scala) is quite successful, and even though we had Akka.net it really never became "mainstream" framework. Personally, think it's not the problem with akka.net itself, but with regular-Joe-.net developer, who uses only what MS releases.  There's Orleans framework, but it's made for specific use case (Halo game on Azure) and should be avoided for general usage IMHO.
  • cloudify all the things. Most of the companies where i worked are slowly switching to the cloud. That brings scaling, resiliency, failover to the list of non-functional requirements. Application needs to be designed differently to accommodate almost-certain outage and downtime of a service, and also to control overall costs.  

What I Like:

  • new domain http://dot.net is totally cool
  • VS Code, since VS Full + Resharper can be unusably slow sometimes. It will force me to learn how to program without Resharper :)
  • exposure to Linux
  • new modular and minimal design of .NET, and whole cross-platform support
  • attention to performance. Just to show off how "my framework is faster than yours" when talking with other devs. Important stuff.
  • Xamarin will get proper attention now, when it’s part of the same company.
  • community standups, great way to hear what’s going on and ask questions

What I Don't Like:

  • changes beta -> rc1 -> rc2. RC2 looks like real beta to me. Think it could be communicated better, in form of; what's todays state, how to install nightly builds and use that with VS Code, what's working and what's not, what are all the "net standard" targets and what the hell do they mean, etc. Community standups are great, but I would like to have one up-to-date web page describing how to setup dev environment and how to pick right target framework
  • Xamarin and .NET Core – I’m guessing some merging will happen, this way it just doesn’t make sense to have 2 frameworks and runtimes doing almost the same job
  • VS becoming even more slower. Has many problems with Update 2, had to completely reinstall VS on one machine, and even reinstall whole Windows on another!
  • whole .NET could be released in more "agile" or incremental way: first core bits, then standard library (one nuget at the time!), then app frameworks like MVC, and so on. So not wait until everything is RTM (framework, web server, libs, tooling, EF, Xamarin, ....) but bunch of small RTMs. Until MVC is RTM, we would have many libraries and frameworks already ported and ready. I think MS is here aiming at regular dark-matter developer who wants the whole package of absolutely everything, but this is framework for next 10y, customer shouldn't be a developer from 2006.
  • like Json.net become a part of official .net, i would like to see more examples like this: for logging (Serilog?), messaging (EasyNetQ?), database (dapper, marten), architecture (akka.net), where MS officially endorse and support some OSS project. I don't mean full SLA where I can call MS in the middle of the night and ask some crazy question, but more from marketing perspective (if that's even possible or makes sense) 
  • Win 10 issues: forced restarts, burned by those several times. Lack of High DPI support. Not related to .net, but I'm just so angry about this. If high DPI doesn't get fixed soon, I'm switching to Mac book.

RC2 is out, VS Code and VS Full have full debugging support, there's no excuses any more to try new platform! It's a call to action!

Looks like 2016 and 2017 will be years of learning new platforms, environments and tools! Maybe it sounds scary, but I can't wait:)