3

I'm updated nginx to 1.23.4, and nginx -t start showing warnings:

nginx: [warn] protocol options redefined for 0.0.0.0:443 in /etc/nginx/sites-enabled/beta:5
nginx: [warn] protocol options redefined for [::]:443 in /etc/nginx/sites-enabled/default:28
nginx: [warn] protocol options redefined for [::]:443 in /etc/nginx/sites-enabled/grafana:5

These lines are

    listen 443 ssl;
    listen [::]:443 ssl;
# sometimes:
#    listen 443 ssl;
#    listen [::]:443;
# I'm now know - some inconsistency, fixed

But after tweaking and adding http2 there were more warnings.

3 Answers 3

4

It turned out that I didn't correct the configuration enough. Corrections must be made on all servers configurations.

To find all the wrong occurrences, you can help yourself:

grep -R /etc/nginx/ -e 443 |grep -v ssl
grep -R /etc/nginx/ -e 443 |grep -v http2

Important: All servers listening on the same port should have identical configuration.

eg.:

listen 443 ssl http2;

#bad:  ssl without http2
listen 443 ssl; 

#ok:   identical protocols as in previous (first) server
listen 443 ssl http2; 

More details are in commit: https://github.com/nginx/nginx/commit/dad65f3e449f215469943628f2b1f12a118fcf7e

2
  • 3
    which corrections did you apply?
    – lrkwz
    May 24, 2023 at 10:07
  • 1
    Some servers I had defined as 443 ssl others 443 ssl http2. After fix all are 443 ssl http2
    – bato3
    Aug 11, 2023 at 13:40
0

It appears that the message shows each time that the nginx configuration processor encounters a listen directive for a given ip address & port combination that is different to the previous one it saw.

So if you have two consecutive server blocks that have the same listen directive then you will NOT get a warning for the second one. If the server block that follows that has a different listen directive (e.g. the same as the first one) then that will trigger another warning.

Ultimately, the solution is to make sure they are all the same, but I hope this extra detail helps somebody somewhere narrow down which of their configuration files they should change.

1
0

I experienced the same issue because the default_server block did not include the ssl directive.

So it should have been:

server {
  listen 443 default_server ssl;
  listen [::]:443 default_server ssl;

  ...
}

instead of

server {
  listen 443 default_server;
  listen [::]:443 default_server;

  ...
}

Note that in other server blocks which also listen on 443, I had included the http2 on; directive, but this was not necessary to include in the default_server to make the warning go away.

You must log in to answer this question.

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