ngx_stream_ssl_preread_module 模块

The ngx_stream_ssl_preread_module module (1.11.5) allows extracting information from the ClientHello message without terminating SSL/TLS, for example, the server name requested through SNI or protocols advertised in ALPN. This module is not built by default, it should be enabled with the --with-stream_ssl_preread_module configuration parameter.

Example Configuration

Selecting an upstream based on server name:

map $ssl_preread_server_name $name {
   backend.example.com      backend;
   default                  backend2;
}

upstream backend {
   server 192.168.0.1:12345;
   server 192.168.0.2:12345;
}

upstream backend2 {
   server 192.168.0.3:12345;
   server 192.168.0.4:12345;
}

server {
   listen      12346;
   proxy_pass  $name;
   ssl_preread on;
}

Selecting an upstream based on protocol:

map $ssl_preread_alpn_protocols $proxy {
   ~\bh2\b           127.0.0.1:8001;
   ~\bhttp/1.1\b     127.0.0.1:8002;
   ~\bxmpp-client\b  127.0.0.1:8003;
}

server {
   listen      9000;
   proxy_pass  $proxy;
   ssl_preread on;
}

Selecting an upstream based on SSL protocol version:

map $ssl_preread_protocol $upstream {
   ""        ssh.example.com:22;
   "TLSv1.2" new.example.com:443;
   default   tls.example.com:443;
}

# ssh and https on the same port
server {
   listen      192.168.0.1:443;
   proxy_pass  $upstream;
   ssl_preread on;
}

Directives

Syntax:

ssl_preread on | off;
   

Default:

ssl_preread off;
   

Context:

stream, server
   

Enables extracting information from the ClientHello message at the preread phase.

Embedded Variables

$ssl_preread_protocol

the highest SSL protocol version supported by the client (1.15.2)

$ssl_preread_server_name

server name requested through SNI

$ssl_preread_alpn_protocols

list of protocols advertised by the client through ALPN (1.13.10). The values are separated by commas.

说说我的看法
全部评论(
没有评论
关于
本网站专注于 Java、数据库(MySQL、Oracle)、Linux、软件架构及大数据等多领域技术知识分享。涵盖丰富的原创与精选技术文章,助力技术传播与交流。无论是技术新手渴望入门,还是资深开发者寻求进阶,这里都能为您提供深度见解与实用经验,让复杂编码变得轻松易懂,携手共赴技术提升新高度。如有侵权,请来信告知:hxstrive@outlook.com
公众号