=encoding utf-8 =head1 NAME ngx_stream_ssl_module - Module ngx_stream_ssl_module =head1 The C module (1.9.0) provides the necessary support for a stream proxy server to work with the SSLETLS protocol. This module is not built by default, it should be enabled with the C<--with-stream_ssl_module> configuration parameter. =head1 Example Configuration To reduce the processor load, it is recommended to =over =item * set the number of worker processes equal to the number of processors, =item * enable the shared session cache, =item * disable the built-in session cache, =item * and possibly increase the session lifetime (by default, 5 minutes): =back worker_processes auto; stream { ... server { listen 12345 ssl; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5; ssl_certificate /usr/local/nginx/conf/cert.pem; ssl_certificate_key /usr/local/nginx/conf/cert.key; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ... } =head1 Directives =head2 ssl_certificate B ssl_certificate I>> B I B I Specifies a I> with the certificate in the PEM format for the given server. If intermediate certificates should be specified in addition to a primary certificate, they should be specified in the same file in the following order: the primary certificate comes first, then the intermediate certificates. A secret key in the PEM format may be placed in the same file. Since version 1.11.0, this directive can be specified multiple times to load certificates of different types, for example, RSA and ECDSA: server { listen 12345 ssl; ssl_certificate example.com.rsa.crt; ssl_certificate_key example.com.rsa.key; ssl_certificate example.com.ecdsa.crt; ssl_certificate_key example.com.ecdsa.key; ... } B Only OpenSSL 1.0.2 or higher supports separate certificate chains for different certificates. With older versions, only one certificate chain can be used. =head2 ssl_certificate_key B ssl_certificate_key I>> B I B I Specifies a I> with the secret key in the PEM format for the given server. The value C:I>:I> can be specified instead of the I>, which loads a secret key with a specified I> from the OpenSSL engine I>. =head2 ssl_ciphers B ssl_ciphers I>> B I B I B I Specifies the enabled ciphers. The ciphers are specified in the format understood by the OpenSSL library, for example: ssl_ciphers ALL:!aNULL:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; The full list can be viewed using the “C” command. =head2 ssl_dhparam B ssl_dhparam I>> B I B I Specifies a I> with DH parameters for DHE ciphers. =head2 ssl_ecdh_curve B ssl_ecdh_curve I>> B I B I B I Specifies a I> for ECDHE ciphers. When using OpenSSL 1.0.2 or higher, it is possible to specify multiple curves (1.11.0), for example: ssl_ecdh_curve prime256v1:secp384r1; The special value C (1.11.0) instructs nginx to use a list built into the OpenSSL library when using OpenSSL 1.0.2 or higher, or C with older versions. B Prior to version 1.11.0, the C curve was used by default. =head2 ssl_handshake_timeout B ssl_handshake_timeout I>> B I<60s> B I B I Specifies a timeout for the SSL handshake to complete. =head2 ssl_password_file B ssl_password_file I>> B I B I Specifies a I> with passphrases for secret keys where each passphrase is specified on a separate line. Passphrases are tried in turn when loading the key. Example: stream { ssl_password_file /etc/keys/global.pass; ... server { listen 127.0.0.1:12345; ssl_certificate_key /etc/keys/first.key; } server { listen 127.0.0.1:12346; # named pipe can also be used instead of a file ssl_password_file /etc/keys/fifo; ssl_certificate_key /etc/keys/second.key; } } =head2 ssl_prefer_server_ciphers B ssl_prefer_server_ciphers I E C> B I B I B I Specifies that server ciphers should be preferred over client ciphers when the SSLv3 and TLS protocols are used. =head2 ssl_protocols B ssl_protocols I< [C] [C] [C] [C] [C]> B I B I B I Enables the specified protocols. The C and C parameters work only when the OpenSSL library of version 1.0.1 or higher is used. =head2 ssl_session_cache B ssl_session_cache I< C E C E [C[:I>]] [C:I>:I>]> B I B I B I Sets the types and sizes of caches that store session parameters. A cache can be of any of the following types: =over =item C the use of a session cache is strictly prohibited: nginx explicitly tells a client that sessions may not be reused. =item C the use of a session cache is gently disallowed: nginx tells a client that sessions may be reused, but does not actually store session parameters in the cache. =item C a cache built in OpenSSL; used by one worker process only. The cache size is specified in sessions. If size is not given, it is equal to 20480 sessions. Use of the built-in cache can cause memory fragmentation. =item C a cache shared between all worker processes. The cache size is specified in bytes; one megabyte can store about 4000 sessions. Each shared cache should have an arbitrary name. A cache with the same name can be used in several servers. =back Both cache types can be used simultaneously, for example: ssl_session_cache builtin:1000 shared:SSL:10m; but using only shared cache without the built-in cache should be more efficient. =head2 ssl_session_ticket_key B ssl_session_ticket_key I>> B I B I Sets a I> with the secret key used to encrypt and decrypt TLS session tickets. The directive is necessary if the same key has to be shared between multiple servers. By default, a randomly generated key is used. If several keys are specified, only the first key is used to encrypt TLS session tickets. This allows configuring key rotation, for example: ssl_session_ticket_key current.key; ssl_session_ticket_key previous.key; The I> must contain 48 bytes of random data and can be created using the following command: openssl rand 48 > ticket.key =head2 ssl_session_tickets B ssl_session_tickets I E C> B I B I B I Enables or disables session resumption through L. =head2 ssl_session_timeout B ssl_session_timeout I>> B I<5m> B I B I Specifies a time during which a client may reuse the session parameters stored in a cache. =head1 Embedded Variables The C module supports variables since 1.11.2. =over =item C<$ssl_cipher> returns the string of ciphers used for an established SSL connection; =item C<$ssl_protocol> returns the protocol of an established SSL connection; =item C<$ssl_server_name> returns the server name requested through L; =item C<$ssl_session_id> returns the session identifier of an established SSL connection; =item C<$ssl_session_reused> returns “C” if an SSL session was reused, or “C<.>” otherwise. =back