21

When I run the command to test my configuration I get an error saying there are multiple duplicates for [::]:80. Before that I had an issue with duplicate multiple default servers.

When I had the issue with multiple default servers, my file looked like this

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

server_name munki;

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
    }

location /report {
    try_files $uri $uri/ =404;
    }

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }

location /munki_repo/ {
    alias /usr/local/munki_repo/;
    autoindex off;
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd;
    }
}

To resolve that problem, I changed the configuration to:

server {
listen 80;
listen [::]:80 ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

server_name munki;

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
    }

location /report {
    try_files $uri $uri/ =404;
    }

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    }

location /munki_repo/ {
    alias /usr/local/munki_repo/;
    autoindex off;
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd;
    }
}

After the change I started getting a "duplicate options for [::]:80" error. I am not sure what I am doing wrong with this. This is my first time working with Nginx. Any ideas what the issue could be?

2
  • Please post the error message (nginx -t output). What nginx version are you running? ipv6only=on might not be needed anymore. I have this in my server block: listen 80;listen [::]:80; and it runs fine. Do you have any other server blocks?
    – simlev
    Commented Apr 4, 2017 at 14:28
  • That worked what you suggested Thanks! Never would have thought of that.
    – ztmcoder
    Commented Apr 4, 2017 at 14:32

1 Answer 1

51

I'm creating an answer out of my earlier comment.

Please post the error message (nginx -t output) as it could contain some useful insight.

What nginx version are you running? Option ipv6only=on might not be needed anymore and on the contrary potentially create issues. I have this in my server block and it runs fine:

listen 80;
listen [::]:80;

Do you have any other server blocks you didn't post that might possibly conflict with eachother?


Explanation: let's read the current (1.13) nginx documentation:

ipv6only=on|off
this parameter (0.7.42) determines (via the IPV6_V6ONLY socket option) whether an IPv6 socket listening on a wildcard address [::] will accept only IPv6 connections or both IPv6 and IPv4 connections. This parameter is turned on by default. It can only be set once on start.

This parameter is turned on by default means that you should not use ipv6only=on. It does not do any good and can potentially create problems (see next point).

It can only be set once means that if you have it more than once anywhere in your configuration (such as in different server blocks), it will throw an error: nginx: [emerg] duplicate listen options for [::]:80.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .