listen directive

Francis Daly francis at daoine.org
Thu Jul 25 08:00:30 UTC 2013


On Thu, Jul 25, 2013 at 03:50:02AM -0400, drook wrote:

Hi there,

> Thanks, I have read this carefully, but this hasn't become more clear for me
> - all the examples contain the IP defined, what about undefined IP (which,
> as I understand, means "listen to this port everywhere") ? Does it receive
> less priority ? Plus, in my case server_name is defined too. I'm not
> complaining, I'm trying to understand better.

A request comes in on an ip:port.

The "listen" directives in each server{} block are considered, to find
the best-match one for that ip:port. Only server{} blocks with that
"listen" directive are considered for the next stage.

(Absent "listen", or "listen" without both a port and address, assume
the default values for the missing parts.)

After that, the server_name is considered, and the one best-match
server_name from the many best-match "listen" servers is chosen.

Is that any clearer? Can you suggest a wording for the manual that might
have made it clearer to you on first reading?

A consequence is that if you want every server{} to be potentially
considered for server_name matching for all requests, you must include
the same best-match "listen" directive in each server{}.

Thanks,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list