5 vnext + nginxYou can run ASP.NET 5 applications on Linux using kestrel web server. This is development web server, so it has limited functionality. But sometimes you need more functions, for example, https or virtual hosts support. Today we will see how to configure a system, so you can access your application through a domain name.

First, you need ASP.NET 5 environment up and running.  You can use my article to install and configure everything, but it's a bit outdated, so it's better to use official documentation.

After you done with your ASP.NET 5 application, run it with following command:

dnx . kestrel

By default, kestrel will start listening port 5004 on default network interface ( So your application will be available here:

You cannot just change port from 5004 to 80, because it is not allowed in Linux to open ports lower that 1024 with default user permissions. And you do not want to run your application as a root.

To fix this issue you can use iptables to redirect all traffic from 80 to 5004 port,  but it's not the best solution, because if you wanna have more that one application listening on the port 80  it will be not possible with iptables. So, we are gonna use nginx to solve this issue.

Install nginx. In Debian-based Linux:

sudo apt-get install nginx

Create server block (virtual host):

sudo nano /etc/nginx/sites-available/

with a following config:

server {
        listen 80;

        location / {
                proxy_set_header    Host $host;
                proxy_set_header    X-Real-IP   $remote_addr;
                proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;

and enable nginx site.

We just configured a reverse proxy. All request to will go to where you have ASP.NET 5 application runned with a kestrel server.

With nginx you can do much more than that. You can use https protocol, enable load balancing, caching, etc.

In the next article, you can find script to run Kestrel in the background and on the system's startup