Opened 4 years ago

Closed 4 years ago

#2118 closed defect (worksforme)

no "ssl_certificate" is defined for the "listen ... ssl" when listen [::]:80 included

Reported by: lukasmatta@… Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.18.x
Keywords: Cc:
uname -a: Linux ubuntu-s-1vcpu-1gb-fra1-01 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f 31 Mar 2020
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-5J5hor/nginx-1.18.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module

Description

Hello,

when I try to run "nginx -t" to test my config files, I get following error:

nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/xyz.com:18
nginx: configuration file /etc/nginx/nginx.conf test failed

When I comment out line "listen [::]:80", config test passes and everything works perfectly.

Here is the config file:

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

    if ($host = www.xyz.com) {
	return 301 https://xyz.com$request_uri;
    }

    server_name xyz.com www.xyz.com;
    index index.html index.htm index.nginx-debian.html;
    root /var/www/xyz.com/web;
    ssl_certificate /etc/letsencrypt/live/xyz.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/xyz.com/privkey.pem;
}

server {
    if ($host = www.xyz.com) {
        return 301 https://$host$request_uri;
    }

    if ($host = xyz.com) {
        return 301 https://$host$request_uri;
    }


    listen 80;
    listen [::]:80; # If I comment out this line, config test passes
    server_name xyz.com www.xyz.com;
    return 404;
}

Is this a problem with the config tester or am I missing something?

Change History (1)

comment:1 by Maxim Dounin, 4 years ago

Resolution: worksforme
Status: newclosed

Is this a problem with the config tester or am I missing something?

The behaviour suggests that listen [::]:80 is defined with the ssl parameter in some other include file.

Note: See TracTickets for help on using tickets.