On shared hosting, hundreds or thousands of sites live on one server, most sharing a single IP address. Over plain HTTP that's easy: the browser sends a Host header and the server picks the site. HTTPS is trickier because the encrypted connection is set up before any HTTP request, so at the moment the server must present a certificate, it doesn't yet know which site is wanted. SNI solves this.
Life before SNI
Early TLS let a server present just one certificate per IP and port, so every HTTPS site needed its own IP address. IPv4 addresses are scarce and increasingly expensive, which made this painful for hosts and customers alike, and many small sites simply stayed on HTTP.
What SNI does at the start of a connection
Server Name Indication is a TLS extension that lets the client name the domain it wants in the very first message, the ClientHello. The server reads that name, selects the matching certificate and returns it. Only then is the encrypted channel established and the HTTP request sent. One IP and port 443 can thus serve any number of domains, each with its own certificate. All modern browsers, operating systems and libraries support SNI; only very old clients, some legacy scripts or misconfigured monitoring tools may omit it.
Multiple certificates in Nginx
server {
listen 443 ssl;
server_name example.uz www.example.uz;
ssl_certificate /etc/ssl/example.uz/fullchain.pem;
ssl_certificate_key /etc/ssl/example.uz/privkey.pem;
}
server {
listen 443 ssl;
server_name misol.uz www.misol.uz;
ssl_certificate /etc/ssl/misol.uz/fullchain.pem;
ssl_certificate_key /etc/ssl/misol.uz/privkey.pem;
}
SNI needs no switch in Nginx. When the client sends misol.uz, the second block is chosen. If no SNI arrives or the name matches nothing, Nginx uses the default server for that port, which is the first block unless you mark one with default_server.
Where "certificate belongs to another site" comes from
A common hosting scenario: a domain already points at the server but has no HTTPS block or certificate yet. Nginx falls back to the default block's certificate, and the browser flags the name mismatch. The fix is to issue a certificate for the domain or add it to the right block. To avoid ever showing a stranger's certificate, make the default block reject unknown names; ssl_reject_handshake is available from Nginx 1.19.4.
server {
listen 443 ssl default_server;
server_name _;
ssl_reject_handshake on;
}
Testing SNI
openssl s_client -connect 192.0.2.10:443 -servername example.uz </dev/null 2>/dev/null \
| openssl x509 -noout -subject -ext subjectAltName
curl -vI --resolve example.uz:443:192.0.2.10 https://example.uz/
Change -servername to see different certificates from the same IP. The curl --resolve trick is handy during migrations: you can verify the new server's certificate before DNS is switched.
Example: a web studio with thirty clients
A small Tashkent web studio runs about thirty client sites on one VPS, from a dental clinic to shops and restaurants, all on one IP with individual Let's Encrypt certificates. Once, a new client's domain was pointed at the server before its certificate was issued, and the site opened with the clinic's certificate. Adding ssl_reject_handshake to the default block turned that confusing warning into a plain connection error that is noticed immediately. sayt.uz hosting works on the same principle: sites share servers and each receives its own free Let's Encrypt certificate via SNI, with nothing for the customer to configure beyond pointing the domain correctly.
SNI and privacy
SNI sends the domain name in clear text, so an observer can see which site you visit even without seeing page content. Encrypted Client Hello (ECH) addresses this by encrypting the ClientHello, including SNI. ECH is being rolled out gradually and depends on browser, DNS and server support.