Concepts / The web

The web

Virtual host

Also called vhost, Host header, name-based hosting, server_name, server block

Many sites on one address and port, told apart by the Host header in each request.

Same address and port, the Host header picks the site
Same address and port, the Host header picks the site

DNS sends both names to the same server. Only the Host header inside the request tells the server which site is wanted; a name it does not know gets the default site.

A virtual host is one of several sites served from the same address and port. DNS only brings the client to the address; the Host header in the request names the site, and the server matches it against each site's names (nginx's server_name). An unknown name goes to the default server. HTTP/1.1 requires the header: without it the server answers 400. Over HTTPS the name travels in the TLS SNI.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab