having nginx listen the same port more than once

Maxim Dounin mdounin at mdounin.ru
Mon Jan 9 15:38:59 UTC 2017


Hello!

On Mon, Jan 09, 2017 at 11:01:40AM +0800, he.hailong5 at zte.com.cn wrote:

> I observe that the nginx runs with no error if there are 
> duplicate listen ports configured in the http server block or 
> stream server block.
> 
> is this behavior as expected? and if a request comes at such a 
> port, which server would serve this request, by radomly or 
> round-robin?

Duplicate listenining sockets are not allowed in stream{} and will 
return "duplicate "..." address and port pair in ..." if you'll 
try to configure duplicate sockets.

In http{}, requests are routed based on the server names 
configured in the servers with the listening socket in question.  
See here for details:

http://nginx.org/en/docs/http/request_processing.html

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx mailing list