nginx

History

Since our beginning to around 2004, we used Apache like everybody else 1; then we switched to lighttpd.

Seduced by a lightweight and alternative solution, we eagerly adopted it.

Then, as I described it in my previous lighttpd post, in 2012 we switched to nginx which was making a break-out outside Russia and was firmly on it’s way to become the most popular web server 2 (it happened in 2019) and at the time had 10% market share and was already the second most popular Open Source web server.

At that time Cherokee was a too young project for us to consider; maybe it will be our next move?

Between 2012 and 2020 we solely relied on nginx, with dynamic applications behind a FastCGI interface; which led Maz to make a patch for cgit.

Today we are hosting more static than dynamic content, and there is an increase of containers even in our personal infrastructure; leading us to use træfik and envoy. So maybe nginx won’t stay in front for long, or even at all.

1

Well, maybe not everyone else… But over 60% of the web and over 90% of the Open Source servers.

Mass virtual hosting

So, here is the nginx implementation of the lighttpd Mass virtual hosting, using the very same structure.

# massvirtualhosting (
set $domain_name  $host;
set $subdomain  '';
if ($host ~ '^(.+)\.([^.]+\.[^.]{2,})$') {
    set $subdomain  $1;
    set $domain_name  $2;
}
root  /home/vhost/$domain_name/$subdomain/root/;
# )

# userdir (
location ~ ^/~(.+?)(/.*)?$ {
    alias  /home/$1/www$2;
    autoindex  on;
}
# )

Sugar-coating, if you have enabled the non-default ngx_http_sub_module, add in the userdir bloc:

autoindex_exact_size off;
sub_filter "<html>\r\n<head><title>" "<!DOCTYPE html>\r\n<html>\r\n<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"robots\" content=\"noindex, nofollow, noarchive, nocache\"/><title>";

2

In the February 2021 survey we received responses from 1,204,252,411 sites across 263,042,054 unique domains and 10,766,606 web-facing computers. This reflects a gain of 6,270,052 sites, 92,829 domains, and 116,789 computers.

nginx is top of the charts when it comes to total count of sites as well as number of unique domains and web-facing computers. 34.5% of all sites run on nginx, 30.4% of domains, and 35.0% of web-facing computers. Apache comes in at seconds place in these metrics, with a 26.3% market share of sites, a similar 26.4% share of domains, and 32.7% of web-facing computers.

https://news.netcraft.com/archives/2021/02/26/february-2021-web-server-survey.html