Ubuntu with XFCE, ASP.NET Core and Nginx, part I
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)