having nginx listen the same port more than once
Igor A. Ippolitov
iippolitov at nginx.com
Mon Feb 13 11:42:22 UTC 2017
Assuming a configuration with multiple similar 'listen' and
'server_name' statements, only the first one will work:
> server {
> listen 9090;
> return 404;
> server_name example.com;
> }
> server {
> listen 9090;
> return 403;
> server_name example.com;
> }
> server {
> listen 9090;
> return 400;
> server_name example.com;
> }
> nginx: [warn] conflicting server name "example.com" on 0.0.0.0:9090,
> ignored
> nginx: [warn] conflicting server name "example.com" on 0.0.0.0:9090,
> ignored
Afaik, the only reply you would be able to get from such configuration
is '404'
On 13.02.2017 10:13, Reinis Rozitis 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?
>
> That is how every webserver capable of name based virtual hosts works.
> So yes it's normal and expected.
>
>> and if a request comes at such a port, which server would serve this request, by radomly or round-robin?
> http://nginx.org/en/docs/http/request_processing.html
>
> rr
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
More information about the nginx
mailing list