<div dir="ltr"><div>Hi,</div><div><br></div><div>I've noticed at least in 1.24.0 and 1.25.4 that adding an ssl_reject_handshake to the default server breaks SNI for other servers. Example:</div><div><br></div><div>```</div><div>server {<br>    server_name _;<br>    listen 80 default_server;<br>    listen 443 default_server ssl;<br>    listen 443 default_server quic reuseport;<br>    listen [::]:80 default_server;<br>    listen [::]:443 default_server ssl;<br>    listen [::]:443 default_server quic reuseport;<br><br>    http2 on;<br><br>    # SSL<br>    ssl_certificate         /etc/pki/lego/certificates/server.crt;<br>    ssl_certificate_key     /etc/pki/lego/certificates/server.key;<br>    ssl_trusted_certificate /etc/pki/lego/certificates/server.crt;<br>    ssl_reject_handshake on;<br><br>    return 444;<br>}</div><div><br></div><div>server {<br>    server_name <a href="http://domain.com">domain.com</a>;<br>    listen 443 ssl;<br>    listen 443 quic;<br>    listen [::]:443 ssl;<br>    listen [::]:443 quic;<br><br>    http2 on;<br><br>    root /srv/www/html;<br><br>    # SSL<br>    ssl_certificate         /etc/pki/lego/certificates/server.crt;<br>    ssl_certificate_key     /etc/pki/lego/certificates/server.key;<br>    ssl_trusted_certificate /etc/pki/lego/certificates/server.crt;<br><br>    location / {<br>        try_files /index.html =404;<br>    }<br>}</div><div>```</div><div><br></div><div>There are two remarks for this example:</div><div>- While enabling HTTP/3 I had to add the ssl_certificate lines to the default server, while using solely HTTP/2 this wasn't necessary. It will throw an error on trying to start Nginx, is that a bug?<br></div><div>- The ssl_reject_handshake in the default server will prevent proper SNI matching for <a href="http://domain.com">domain.com</a>. If I run `curl <a href="https://domain.com/`">https://domain.com/`</a> it works fine, but `curl -k -H 'Host: <a href="http://domain.com">domain.com</a>' <a href="https://ipaddress-of-server/`">https://ipaddress-of-server/`</a> does not. When I remove ssl_reject_handshake it works as expected</div><div><br></div><div>My intent is to have a default server that responds to non-existing domain names. Preferably it responds with 444, but requests over TLS (such as old domains names with HTST) will throw a security warning that the server's certificates don't match the request's virtual host's domain name (as expected). Instead of showing a security warning in the browser I prefer a connection error, which is why I want to employ ssl_reject_handshake.<br></div><div><br></div><div>Kind regards,</div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Taco de Wolff</div></div></div></div></div></div></div></div></div>