Default website

A "default" website is the website a webserver will fall back to when there is no other website configured with a specific name. For instance, if my webserver only knows about https://example.com/ and https://www.example.com/, but not https://test.example.com/, the last one would show the "default" website.

How does nginx determine which is the default?

Also known as "fallback". There are currently two ways for nginx to determine which is the default website:

Example: Default specified with default_server.

In the following example, you can see that default_server is being used:

server {
    listen 80;
    server_name example.com;
    ....
}

server {
    listen 80 default_server;
    server_name www.example.com;
    ....
}

In this example, if I would request https://test.example.com/, I would get the website of https://www.example.com/ as that has the default_server set in the listen-directive.

Example: Behaviour with no default specified.

And below, without:

server {
    listen 80;
    server_name example.com;
    ....
}

server {
    listen 80;
    server_name www.example.com;
    ....
}

In this example, if I would request https://test.example.com/, I would get the website of https://example.com/ as there is no default_server was set in any listen-directive.