# ngx\_stream\_ssl\_preread\_module

* [示例配置](#example_configuration)
* [指令](#directives)
  * [ssl\_preread](#ssl_preread)
* [内嵌变量](#embedded_variables)

`ngx_stream_ssl_preread_module` 模块（1.11.5）允许从 [ClientHello](https://github.com/DocsHome/nginx-docs/tree/f6135c42a499e9fab0adb433738fcf8cd4041627/%E6%A8%A1%E5%9D%97%E5%8F%82%E8%80%83/stream/ClientHello/README.md) 消息中提取信息，而不会终止 SSL/TLS，例如提取通过 [SNI](https://tools.ietf.org/html/rfc6066#section-3) 请求的服务器名称。默认情况下不构建此模块，您可以在构建时使用 `--with-stream_ssl_preread_module` 配置参数启用此模块。

## 示例配置 <a href="#example_configuration" id="example_configuration"></a>

```
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;
}
```

## 指令 <a href="#directives" id="directives"></a>

### google\_perftools\_profiles

|       - | 说明                              |
| ------: | ------------------------------- |
|  **语法** | **ssl\_preread** `on` \| `off`; |
|  **默认** | ssl\_preread off;               |
| **上下文** | stream、server                   |

启用在[预读阶段](https://github.com/DocsHome/nginx-docs/tree/f6135c42a499e9fab0adb433738fcf8cd4041627/%E6%A8%A1%E5%9D%97%E5%8F%82%E8%80%83/stream/stream_processing.md#preread_phase) 从 ClientHello 消息中提取信息。

## 内嵌变量 <a href="#embedded_variables" id="embedded_variables"></a>

*   `$ssl_preread_server_name`

    返回通过 SNI 请求的服务器名称

## 原文档

[http://nginx.org/en/docs/ngx\_google\_perftools\_module.html](http://nginx.org/en/docs/ngx_google_perftools_module.html)
