I am curious as of why there is a need to specify a server_name in the nginx configuration file on top of the listen property.
I have been reading a digitalocean article on understanding nginx configuration file, and this is how it explains the difference between the two settings:
listen: The ip address / port combination that this server block is designed to respond to. If a request is made by a client that matches these values, this block will potentially be selected to handle the connection.
server_name: This directive is the other component used to select a server block for processing. If there are multiple server blocks with listen directives of the same specificity that can handle the request, Nginx will parse the "Host" header of the request and match it against this directive.
But how could there be two different servers listening on the same ip and the same port? Linux would not even allow you to start two services listening on the same port as far as I know.
What am I missing?
Thanks!


example.comandexample.orgat the same IP.example.com. Nginx looks for aserver {}block with aserver_nameofexample.com. If a request comes in forexample.org, it looks for a server block withexample.orgin theserver_name.