Skip to content

Did you know?

Nginx uses the TLS session cache of the default server on each port, so set ssl_session_cache in the http block.

Set ssl_session_cache and ssl_session_timeout in the http context, not only per site.

  • Web servers
  • Applies to Nginx
  • Last checked

Explained

If your HTTPS sites set ssl_session_cache only inside their own server blocks, and a different server is the default_server on port 443 (for example a catch-all with ssl_reject_handshake on), TLS session resumption silently stops working. In our test, 0 of 5 reconnects were resumed. With the same settings in the http context, 5 of 5 were:

$ openssl s_client -connect example.com:443 -tls1_2 -reconnect -no_ticket < /dev/null | grep -E '^(New|Reused)'
New, TLSv1.2, Cipher is ECDHE-ECDSA-AES256-GCM-SHA384
Reused, TLSv1.2, Cipher is ECDHE-ECDSA-AES256-GCM-SHA384
...

Put ssl_session_cache shared:SSL:10m; and ssl_session_timeout 1d; in a file in /etc/nginx/conf.d/ (http context) so every server, including the default one, shares them.

Learn more

← All tech tips · Suggest a fix

Back to top