Welcome! Log In Create A New Profile

Advanced

having nginx listen the same port more than once

Posted by Anonymous User 
Anonymous User
having nginx listen the same port more than once
January 09, 2017 04:10AM
Hi,





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?




Thanks,

Joe_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: having nginx listen the same port more than once
January 09, 2017 04:40PM
Hello!

On Mon, Jan 09, 2017 at 11:01:40AM +0800, he.hailong5@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/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login