ssl_reject_handshake

When using Nginx's stream module to route HTTPS traffic based on Server Name Indication (SNI), unknown hostnames should be rejected as early as possible.

A common approach is to forward unmatched SNI requests to a default HTTPS server and use return 444 to close the connection. However, Nginx provides a more efficient solution: ssl_reject_handshake on.

This article explains the configuration and why it is a better fit for this scenario.

1. Architecture

The setup uses the Nginx stream module to inspect TLS ClientHello messages and route connections according to their SNI hostname.

 

stream {
    map $ssl_preread_server_name $stream_map {
        example.com ...