Welcome! Log In Create A New Profile

Advanced

Mixing listen directives in http/server

Posted by rihad 
Mixing listen directives in http/server
November 03, 2024 12:30PM
Hi, all. After the upgrade to nginx 1.26.2 I started facing this warning:

nginx: [warn] protocol options redefined for 0.0.0.0:443 in /path/to/123456.conf:8

Here's how configuration is laid out. There's one http clause under which a number of name-based servers are included from /path/to/*.conf and then comes this server:

server {
listen 80 default accept_filter=httpready rcvbuf=8k;
location / { deny all; }
}
server {
listen 443 ssl default_server accept_filter=dataready;
ssl_certificate ssl/self-ssl.crt;
ssl_certificate_key ssl/self-ssl.key;
ssl_stapling off;

location / { deny all; }
}

/path/to/*.conf files look like this:

server {
http2 on;
listen 80;
listen 443;
...

I can put ssl after 443 - it doesn't matter, it will still give the same warning. If I duplicate the listen clause from http

listen 443 ssl accept_filter=dataready;

nginx errs out with:
nginx: [emerg] duplicate listen options for 0.0.0.0:443 in /path/to/nginx.conf:47

If I completely remove listen directives from /path/to/*.conf, the said name based hosts aren't found resulting in HTTP 403.

So how do I get it working without warnings? For some reason listen 80 is ok, nginx doesn't complain about it at all.

Thanks.
Re: Mixing listen directives in http/server
November 04, 2024 03:02PM
Problem solved) If all listen 443 lines in all files have the same options - there will be no warnings. In my case

listen 80;
listen 443 ssl;

in all included files and the "catch-all":

listen 80 default accept_filter=httpready rcvbuf=8k;
listen 443 ssl default accept_filter=dataready;

at http level. Options other than ssl were ignored (and even resulted in a duplicate error if I tried to copy the accept_filter part, for instance).
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 221
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready