One server, many domains: how traffic is distributed

Published on 2026-09-12 by frfrand

How a server with a single IP handles ten sites, what SNI is, why the first nginx block is special, and how to prevent one domain from serving another's content.

One server, many domains: how traffic is distributed

Short answer: a server with a single IP handles many domains because the browser announces which name it is coming for: in HTTP with the Host header and in HTTPS with the SNI, within the first handshake message. nginx compares that name with the server_name and chooses the block; if none matches, it uses the default block, which is worth defining on purpose so that the wrong site does not respond.

You have a server with a single public address. You want to host ten different sites, each with its own domain and certificate. How does the server know which one to serve?

The answer is that the browser says so. Before requesting anything, it announces which name it is coming for.

In HTTP it is easy

When the browser opens the connection, it sends a header:

GET /precios HTTP/1.1 Host: tienda.ejemplo.com

nginx reads that Host, compares it with the server_name of its blocks and chooses the corresponding one. Each site is a server block in its own file, all listening on the same port.

In HTTPS there is an ordering problem

With HTTPS comes a chicken-and-egg problem: the certificate must be presented at the beginning of the handshake, before there is an HTTP request where the Host can be read. What certificate does the server present if it still does not know which site is being requested?

The solution is called SNI (Server Name Indication): the client includes the domain name in the first handshake message, in clear text. The server reads that name, chooses the correct certificate and continues.

That's why today a server can have twenty certificates and present the corresponding one. Before SNI, an address was needed per certificate, which is part of why shared hosting with HTTPS was expensive.

A surprising detail: since SNI travels unencrypted, the network can see which domain you connect to, even though it cannot see the content.

The default block, where it breaks

This is the part that causes the most baffling problems.

If a request arrives with a name that does not match any server_name, nginx does not return an error: it delivers it to the first block listening on that port. And "the first" depends on the alphabetical order of the files, which no one chose on purpose.

Typical symptoms:

  • A new domain, for which you haven't configured the block yet, shows another client's site.
  • Scanners entering through the public address see a real website instead of nothing.

The solution is five lines:

server { listen 443 ssl default_server; server_name _; ssl_reject_handshake on; return 444; }

444 is an nginx-specific code that means "close the connection without responding". Whoever did not request a known domain receives nothing. And as a side effect, a misconfigured domain stops failing silently: it fails obviously, which is much better.

A costly mistake

The order of the blocks matters, but the order of the matches also matters. nginx prefers exact match over wildcard. If you have:

server_name *.ejemplo.com; server_name app.ejemplo.com;

a request to app.ejemplo.com goes to the second one, even if the first one is earlier in the file. That is what you want almost always, but it is worth knowing because it explains why sometimes "the order does not matter" and sometimes it does.

How it is solved in ArduMaker

In ArduMaker the distribution is done in two floors. The nginx of the host that hosts your VPS is the one that reads the SNI and presents the certificate of each domain: the platform issues it when activating the domain, if you request it, and the subdomains of one level of the platform zone are already covered by its wildcard certificate. Then it passes the request to the nginx of your VPS, where each domain needs its server block.

That internal block is written by the deploy of a repository or you write it from the nginx editor of the panel, which validates with nginx -t before applying and leaves everything as it was if it fails. And the nginx of each VPS already comes with a default_server block: a name that does not have its block receives an ArduMaker notice page, not another site's site.

The advantage of those pieces coming resolved is not saving yourself the work of writing twenty lines: it is that site number ten ends up just as well configured as the first one, six months later and with another person doing it.

One server, many domains: how traffic is distributed
One server, many domains: how traffic is distributed

Example: two domains on the same VPS

Suppose that app.ejemplo.com corresponds to a frontend and api.ejemplo.com to FastAPI. Both domains can point to the same public IP; Nginx distinguishes the requested name and directs each request to its internal service.

In ArduMaker you can manage domains and applications on the VPS, avoiding hiring a separate server for each name when it is not necessary. The VPS capacity, the required isolation, and the traffic pattern determine how far it is worth sharing resources.

Related: What is Nginx · What is an IP.

Frequently Asked Questions

What is SNI? Server Name Indication: the client includes the domain in the first message of the TLS handshake so the server knows which certificate to present. It travels unencrypted, unless ECH is used, which is still not widely adopted.

Why does my new domain show another site? Because it doesn't have a block with its server_name and nginx sent it to the default block, which if you didn't define it is the first one it finds.

What does return 444 do? It closes the connection without responding anything. It is an nginx-specific code, useful in the default block.

If I have a wildcard and an exact name, which wins? The exact name, regardless of the order in the file.

  • nginx
  • dominios
  • SSL
  • ArduMaker
  • hosting

On ArduMaker

  • Domains and SSL: A free subdomain or your own domain with Let's Encrypt, an nginx proxy with rollback, and port forwarding.

Keep reading

All articles · VPS plans