Back to all articles
Linux & Servers2026-07-17

Configuring High-Security SSL/TLS on Nginx (Grade A+)

Learn how to configure advanced SSL/TLS encryption on your Nginx server to protect user browsing and achieve a top score on SSL Labs.

The security of data transmitted over the web is mandatory for any serious business. The basic use of HTTPS certificates (like Let's Encrypt) is already common, but the default configuration of the Nginx web server often accepts old and insecure encryption ciphers and protocols for compatibility reasons.

In this network engineering tutorial, we show you how to perform SSL/TLS protocol hardening on Nginx to secure your connections and achieve the maximum grade (A+) in the global security test by Qualys SSL Labs.

1. Disabling Obsolete Protocols (TLS 1.0 and 1.1)

Legacy protocols like SSLv3, TLS 1.0, and TLS 1.1 have known flaws (such as POODLE and BEAST). We must only accept connections based on TLS 1.2 and TLS 1.3 versions.

In the Nginx configuration server block:

ssl_protocols TLSv1.2 TLSv1.3;

2. Defining Strong Encryption Ciphers

Avoid ciphers based on vulnerable encryption algorithms, such as RC4 or 3DES. Modern ciphers with secure key exchange using elliptic curves (ECDHE) are more robust and faster.

ssl_prefer_server_ciphers off;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305';

The ssl_ciphers directive only applies to TLS 1.2; TLS 1.3 uses its own suites, all of them secure. Since every cipher in the list is strong, Mozilla's intermediate configuration uses ssl_prefer_server_ciphers off and lets the client pick the fastest one for its hardware (ChaCha20 on phones without AES acceleration). The DHE ciphers are only used if ssl_dhparam is configured.

3. Implementing HSTS (Strict Transport Security)

HSTS is an HTTP response header that instructs the browser to force any future connection strictly via HTTPS, preventing Man-in-the-Middle interception attacks during HTTP-to-HTTPS redirects.

Add the line in Nginx:

add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;

SSL Labs requires HSTS with a max-age of at least 6 months for an A+; preload is not needed. Use includeSubDomains only when every subdomain answers over HTTPS. preload enrolls the domain in the list built into browsers (hstspreload.org) and is hard to undo: removal takes months. Add it only after you have confirmed HTTPS on every subdomain.

4. Performance Optimization (Session Resumption and OCSP)

Encrypting connections consumes CPU processing. Optimize these handshakes to ensure the end-user's browsing experience remains fast:

  • SSL Session Cache: Saves parameters of recent connections in RAM, speeding up the return of the same visitor.
  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 1d;
  • OCSP Stapling: The server itself checks the validity of the certificate with the certificate authority and staples the response to the TLS handshake, sparing the visitor an extra lookup to the CA. Let's Encrypt shut the service down in 2025, and its certificates no longer carry a responder URL. With those certificates, leave ssl_stapling out: Nginx ignores the directive and logs a warning. The two lines below belong only on a certificate whose CA still publishes an OCSP responder:
  # Only for a CA that still publishes OCSP. On Let's Encrypt, delete both lines.
  ssl_stapling on;
  ssl_stapling_verify on;

When nginx -t rejects the configuration

  • sudo nginx -t names the file and the line. An OCSP warning in the log, with a Let's Encrypt certificate, does not fail the test: delete ssl_stapling, as in section 4.
  • A bad protocol or cipher shows up as invalid value. Go back to the TLS 1.2 and 1.3 pair from section 1 and reload with sudo systemctl reload nginx.
  • The certificate and the key must be a pair. The hash from openssl x509 -noout -modulus -in fullchain.pem | openssl md5 must match the key's hash.

Conclusion

Configuring SSL/TLS in an optimized manner protects your customers' sensitive data (such as credit cards and login details). HTTPS counts as a lightweight ranking signal in Google, but the SSL Labs grade itself does not improve SEO. By implementing these policies on your Nginx server, you ensure the highest level of data integrity in the market.

Managed KVM VPS

ExpertCore provisions and runs the VPS: isolated KVM, backups, and engineering support.

See VPS plans