Startup error -> "duplicate listen options" if 2nd IPv6 listener is enabled

I run src-built nginx/1.3.2 on linux/64.

I have two nginx vhosts enabled:
site 1)

server {
server_name test1.loc;
listen 10.0.0.1:443;
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

site 2)

server {
server_name test2.loc;
listen 10.0.0.1:443 default;
# listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;
…[code]

With this config, if I start nginx,

service nginx start
Shutting down nginx done
Starting nginx done

all’s well.

But, if for site 2) I enable the IPv6 listener,

  • listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

  • listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

Now, @ nginx start,

service nginx start
Starting nginx nginx: [emerg] duplicate listen options for
[2001:xxx:xxxx:xxx::1]:443 in
/usr/local/etc/nginx/sites-enabled/test2.loc.conf:21
startproc: exit status of parent of /usr/local/sbin/nginx: 1

                             failed

Is this a bug, feature or config problem?

Thanks.

Posted at Nginx Forum:

Today Jul 3, 2012 at 13:39 pgn wrote:

[2001:xxx:xxxx:xxx::1]:443 in
/usr/local/etc/nginx/sites-enabled/test2.loc.conf:21
startproc: exit status of parent of /usr/local/sbin/nginx: 1

                             failed

Is this a bug, feature or config problem?

Module ngx_http_core_module
A listen directive can have several additional parameters specific to
system calls listen() and bind(). They can be specified in any listen
directive, but only once for the given address:port pair.


WNGS-RIPE

Sorry, I don’t understand your point.

Why is this ok, and fully functional?

server { server_name test1.loc;
listen 10.0.0.1:443;

server {server_name test2.loc;
listen 10.0.0.1:443;

but this is not?

server { server_name test1.loc;
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

server {server_name test2.loc;
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

Today Jul 3, 2012 at 14:12 pgn wrote:


listen directive without additional parameters.

but this is not?

server { server_name test1.loc;
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

server {server_name test2.loc;
listen [2001:xxx:xxxx:xxx::1]:443 ipv6only=on;

Additional parameters specified twice.

In BOTH cases, BOTH server{} are listening on the same address:port,
differentiated by server_name for vhost redirection.

Additional parameters can be specified only once for the given
address:port pair.


WNGS-RIPE

Done.

Reading the docs, it’s not clear to me – or others apparently:

Name-Based Virtual Hosts With nginx on IPv6 | Kromey's Adventures
nginx name-based virtual hosts on IPv6 - Server Fault

– that ipv6only=on can only be specified once …

While some ‘additional parameters’ on the listen line are restricted in
this manner, others – e.g., ssl, spdy – are not, and can appear
multiple times.

Posted at Nginx Forum:

Today Jul 3, 2012 at 15:04 pgn wrote:

this manner, others – e.g., ssl, spdy – are not, and can appear
multiple times.

You should read docs more careful.
Module ngx_http_core_module
ssl this parameter (0.7.14) does not relate to system calls listen()
and bind(),
but allows to specify that all connections accepted on this port
should work in the SSL mode.


WNGS-RIPE