New website infrastructure

Hi all, first of all I'd like to welcome you on my new website. Even though I "just" took the design of an old website to adapt it on this one, there are a lot of changes behind the scene.

Spoiler alert, this website is currently running using ASP.NET Core on a Raspberry Pi Model B+ running Raspbian Jessie, behind a Nginx caching reverse proxy secured with SSL.

There is a quite interesting story to understand how I ended up with such an infrastructure. Here is a summary :

First version of this website

The first time I brought this website online, I rented a VPS (Virtual Private Server) in order to host several sites and some applications. It was running a Debian Wheezy using a classic stack with Apache, PHP and MySQL.

I used CakePHP to develop the first version, a very pleasant PHP MVC framework.

Self-hosting paradise

The dedicated server solution is very pleasant, but is not cheap in the end. After several years, I did not have the same needs, and I just wanted to host some simple websites. Since I have a very good fiber internet connection, I decided to copy all my websites on my Raspberry Pi model B+, and host my own web server.

To ease the transfer, I installed the same classic stack with Apache, PHP and MySQL, and quickly got my websites back online.

At this time, I started to develop web services and used a Plex media center and I added reverse proxy functionnalities to Apache web server. With 3 PHP websites and some services/medias dispatched using reverse proxy, the Raspberry Pi started to slow down.

The current solution

The previous solution is quite interesting, but I'm not a web developper anymore, and trying to integrate some changes in a PHP website after several years without using PHP is a very hard task. Everyday I develop C# and C++ code using Visual Studio, and I needed a more professional way to maintain my website, using well known debuggers and modern technologies.


In the meantime, Microsoft released the first version of ASP.NET Core, a new server-independent web framework based on ASP.NET, with the promise of multiplatform compatibility.

They also created a new web server 'Kestrel', which is able to run ASP.NET Core websites on several platforms, including Mac and Linux, but only for x86 architectures.

Yay, I'm a .NET specialist, I won't give up this easily. So I tried hard to get everything working on ARM architecture. After some hard work, I finally managed to get everything working on my Raspberry Pi (you can read more details on how to setup such a configuration here : ASP.NET Core on Mono on Linux)


ASP.NET Core websites do not need a web server to be hosted. They are self-hosted binaries, where a website lives in a single process. You need, and it is strongly advised, to used a reverse proxy to expose your website/application to the web.

I had already read some articles about Nginx, being much more memory-efficient and faster than Apache, and that's a BIG point on a Raspberry Pi with only 512 MB of RAM, it is also more CPU friendly. I decided to try it and I am totally convinced now. It uses a simple configuration syntax as shown in the example below.

Nginx is also able to cache requests passing through the reverse proxy, and thus avoid to query the web server if static content is accessed.

For example, here is how to expose a web server (ASP.NET Core, Apache, or any web service) through Nginx reverse proxy :

    listen 80;

    location /
        proxy_pass http://192.168.1.XXX:5000;


I always thought of SSL certificates to be expensive, hard to understand and to setup. Recently, I heard of Let's Encrypt, a service providing free certificates and a good documentation on how to setup major web servers (including Apache and Nginx).

I decided to give it a try, and after a few steps I got my first website running with the famous HTTPS green symbol. A few more steps, and I got the certificate to automatically check for renewal twice a day, as advised.

HTTPS is now fully working on domain and subdomains, from the client browser to my Nginx server. Internal networking for my web services and my website is done using classic HTTP to ease debugging, then served using HTTPS to client. During my development, I can forget about HTTPS stuff as Nginx is taking care of everything for me in reverse proxy.


My current solution is very pleasant to work with. I use Visual Studio and its debugger to develop my website with IIS Express on my computer, then I just have to build and copy the website on my Raspberry Pi to update it.

My website is now super fast thanks to Nginx caching, even on my old Raspberry Pi. The CPU usage is lower, and memory consumption too (expect 5 MB per worker instead of 20 MB with Apache).

ASP.NET Core eats up more memory, with 120 MB usage for a debug version of this website, with in-memory caching and compiled Razor views. I still need to test the Release version, with Razor views pre-compiled ahead of time.

// Restons en contact

Si vous êtes intéressés par mon travail ou mes projets, vous pouvez me suivre et me contacter sur les réseaux suivants :

// Statistiques