A padlock icon in the address bar doesn’t mean TLS is configured correctly. On the same server, TLS 1.0 may still be enabled, an intermediate certificate may be missing, or HSTS may have been published hastily with includeSubDomains. These come back as findings in a security scan, connection errors in API clients and sometimes as a decision that can’t be reversed for months. Below we cover protocol and cipher selection in Nginx and Apache, serving the chain, the HSTS decision and verification, in the order they should be followed in practice.
TLS versions and compatibility
The versions that should be enabled on a web server today are TLS 1.2 (RFC 5246) and TLS 1.3 (RFC 8446). TLS 1.0 and 1.1 were formally deprecated by RFC 8996; modern browsers don’t connect with these versions either. If SSLv2 or SSLv3 is enabled, there’s nothing to discuss. That’s a direct vulnerability.
TLS 1.3 reduces the handshake to one round trip, removes static RSA key exchange and CBC-based ciphers entirely, and makes forward secrecy mandatory. TLS 1.2 is still secure with the right cipher suites and is needed for compatibility with older clients.
| Version | Status | Recommendation |
|---|---|---|
| SSLv3, TLS 1.0, TLS 1.1 | Deprecated | Disable |
| TLS 1.2 | Current, with AEAD ciphers only | Keep enabled |
| TLS 1.3 | Current | Enable |
Before deciding, think about who connects to your corporate website: only browsers, or also an old ERP module, a payment provider’s callback or embedded devices in the field? Adding the $ssl_protocol and $ssl_cipher variables to the access logs and looking at a few weeks of real usage lets you answer this question with data, not guesswork. Don’t make the decision to disable a protocol without seeing this data; if a payment provider’s callback silently fails, the site keeps opening, so accounting is the first to notice.
Cipher suite selection and profiles
Don’t copy a cipher list from forum answers or an old server. The SSL Configuration Generator maintained by Mozilla is a current and consistent starting point; it offers three profiles:
- Modern: TLS 1.3 only. The strictest option; older clients can’t connect.
- Intermediate: TLS 1.2 and 1.3; on the TLS 1.2 side, only AEAD ciphers with ECDHE/DHE key exchange (AES-GCM, ChaCha20-Poly1305). The recommended profile for general-purpose sites.
- Old: For very old clients; should be used only if there’s a specific dependency that requires it, and on a separate endpoint.
In the Intermediate profile, server cipher preference is off (ssl_prefer_server_ciphers off): since all the ciphers in the list are strong, the client is allowed to choose the one that suits its hardware (for example ChaCha20 on a mobile device without AES acceleration). TLS 1.3 cipher suites (TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256) are managed separately by OpenSSL; the default use of Nginx’s ssl_ciphers and Apache’s SSLCipherSuite doesn’t affect them.
The certificate key type is a decision too: ECDSA P-256 keys are smaller and faster in the handshake; RSA 2048 gives the widest compatibility. Nginx and Apache can serve both an RSA and an ECDSA certificate together for the same site; the client gets the one it supports. If there’s a compatibility debate, this is the least risky path.
Setting up the certificate chain correctly
The client must be able to build a chain from the server certificate to a root it trusts. The server is responsible for sending its own certificate and the intermediate certificates; the root certificate isn’t sent, as it’s already in the client’s store.
- Nginx:
ssl_certificatetakes a single file; this file must contain the server certificate first, followed by the intermediate certificates. If you use Certbot, usefullchain.pem, notcert.pem. - Apache: Since 2.4.8,
SSLCertificateFilecan also contain intermediate certificates;SSLCertificateChainFileis considered deprecated from that version.
This is exactly the most common TLS mistake in the field: a site set up with cert.pem. The browser opens it, the API client doesn’t.
Before replacing them, verify that the certificate and private key match by comparing the SHA-256 value of the public key on both sides; this method works the same way for RSA and ECDSA:
openssl x509 -in fullchain.pem -noout -pubkey | sha256sum
openssl pkey -in privkey.pem -pubout | sha256sum
# The two outputs must be the same.
OCSP stapling was the standard recommendation for a long time; but some certificate authorities (including Let’s Encrypt) have ended their OCSP service and moved to publishing revocation information via CRLs. Before enabling stapling, check whether your CA’s certificates contain an OCSP address; if there’s no address, this setting produces nothing but warnings in the error logs. Obtaining and renewing certificates automatically is a separate process, covered in the Let’s Encrypt certificate automation guide.
The HSTS and preload decision
HTTP Strict Transport Security (RFC 6797) tells the browser to connect to this domain only over HTTPS for a set period. After the first visit, even if the user types http:// in the address bar, the browser converts the request to HTTPS itself; this prevents an attacker on the network from hijacking the first plain HTTP request (SSL stripping) and removes the “proceed anyway” option on certificate errors.
HSTS has three parameters, and each carries its own risk:
| Parameter | Effect | Risk |
|---|---|---|
max-age |
How long the rule is stored in the browser | No going back to HTTP until it expires |
includeSubDomains |
Covers all subdomains | Internal or old subdomains without HTTPS become unreachable |
preload |
Permission to apply to browsers’ built-in list | Getting off the list can take months |
The safe transition order: first redirect all HTTP requests to HTTPS with a 301; then publish HSTS with max-age=300; take an inventory of all subdomains and verify that they’ve moved to HTTPS; raise the value to one year over a few weeks; only then add includeSubDomains and, if needed, preload. The preload application is made via hstspreload.org and requires a max-age of at least one year plus the includeSubDomains and preload directives. If there’s an intranet, a printer interface or an old application under the domain that can’t be moved to HTTPS, don’t apply for preload. It’s the hardest decision to reverse.
Nginx and Apache configuration examples
The examples below are based on the Mozilla Intermediate profile; before copying the cipher list, get the current output from the generator for your server and OpenSSL version.
Nginx
server {
listen 443 ssl;
http2 on;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
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;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_session_tickets off;
add_header Strict-Transport-Security "max-age=63072000" always;
}
add_header inheritance sets the same trap as proxy headers: if another add_header is defined in a location block, all add_header directives at server level become invalid for that location and the HSTS header silently disappears. Collecting security headers in a snippet file and including it with include in every block that needs it prevents this problem. The always parameter makes sure the header is also sent on error responses. This inheritance is the common reason for the “HSTS missing on some pages” finding in scan reports.
Apache (mod_ssl and mod_headers)
<VirtualHost *:443>
ServerName www.example.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLCipherSuite 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
SSLHonorCipherOrder off
SSLSessionTickets off
Header always set Strict-Transport-Security "max-age=63072000"
</VirtualHost>
Disabling session tickets prevents tickets whose keys aren’t rotated regularly from weakening forward secrecy; session reuse continues through the shared session cache. In Apache, SSLSessionCache is usually defined globally in the distribution’s default ssl.conf file; check it. On both servers, run nginx -t or apachectl configtest before making changes. For server selection and Apache-specific settings, see the Apache HTTP Server setup and optimization service page.
Verification tools and common mistakes
A padlock icon isn’t verification. Test the configuration at protocol level:
# See the chain and the handshake (-servername is required for SNI)
openssl s_client -connect www.example.com:443 -servername www.example.com -showcerts </dev/null
# Is the old protocol rejected? (This command is expected to fail)
openssl s_client -connect www.example.com:443 -servername www.example.com -tls1_1 </dev/null
# Certificate expiry date
echo | openssl s_client -connect www.example.com:443 -servername www.example.com 2>/dev/null | openssl x509 -noout -enddate
# HSTS header
curl -sI https://www.example.com | grep -i strict-transport-security
# Comprehensive scan (protocols, ciphers, chain, known vulnerabilities)
./testssl.sh https://www.example.com
Note: if the OpenSSL build on your system has also disabled TLS 1.1 on the client side, the second command fails regardless of the server; in that case confirm the result with the testssl.sh output. testssl.sh also works on internal servers without internet access, so it’s suitable for systems that can’t reach external scanning services.
| Symptom | Why | Fix |
|---|---|---|
| The browser opens it, but curl or the API client gives an error | Missing intermediate certificate | Use fullchain.pem |
| The wrong certificate is returned | SNI doesn’t match, the default server block responds | Check server_name and default_server |
| HSTS is missing on some pages | add_header inheritance inside a location |
Define the headers in every block with a snippet |
| A subdomain is unreachable | Premature includeSubDomains |
Enable it after the inventory |
| The scan shows TLS 1.0 enabled | Another virtual server or port has different settings | Define the settings at global level too |
In Nginx, ssl_protocols can be affected by the settings of the default server block on the same IP:port; defining the same protocol setting at http level across all virtual servers prevents inconsistency. If there’s a CDN such as Cloudflare in front, the TLS setting the client sees is the CDN’s edge setting; for the connection between the origin server and the CDN, a validating mode such as “Full (strict)” should be chosen separately. “Flexible” mode leaves the link between the CDN and the origin unencrypted.
Implementation checklist
- Only TLS 1.2 and 1.3 are enabled, consistently across all virtual servers and ports.
- TLS 1.2 ciphers are only ECDHE/DHE-based AEAD suites.
- The server certificate and intermediate certificates are served together; the key match has been verified.
- There’s a 301 redirect from HTTP to HTTPS; HSTS has been increased gradually.
- The preload decision was made after the full subdomain inventory was taken.
- The certificate expiry date is monitored; a testssl.sh scan is repeated after every configuration change.
TLS only protects transport. Application vulnerabilities, security headers and attack filtering are a separate layer; they’re the subject of web application security and WAF work. How protocol information is passed to an application behind a reverse proxy is explained in the Nginx reverse proxy configuration article. You can examine the effect of file and connection controls in production with an independent web application security assessment.
Frequently asked questions
Is it right to disable TLS 1.2 and use only TLS 1.3?
It’s possible if your visitors and the systems that connect to your site support TLS 1.3; Mozilla’s Modern profile recommends it. But older operating systems, embedded devices, some corporate proxies and integrations working with old libraries may not support TLS 1.3. On corporate sites, the Intermediate profile with both TLS 1.2 and 1.3 enabled is the right balance in most cases; make the decision by looking at the protocol distribution in the access logs.
What should the HSTS max-age value be?
During the transition, it’s safe to start with a short value (for example 300 seconds) and increase it gradually after verifying that all subdomains work without problems over HTTPS. In the permanent state, one year (31536000) or two years (63072000) is common; the preload list requires at least one year.
Why do some clients give an untrusted certificate error even though the certificate is valid?
The most common reason is that the intermediate certificate isn’t served. Since browsers can complete a missing intermediate certificate from their cache or via AIA information, the problem isn’t visible on desktop; curl, Java, mobile apps and API clients, however, reject the connection. Use the fullchain file in Nginx and see the whole chain in the openssl s_client output.
Can I change TLS 1.3 cipher suites with ssl_ciphers in Nginx?
No. ssl_ciphers affects only TLS 1.2 and earlier. TLS 1.3 cipher suites are managed separately by OpenSSL, and the three default suites are secure; in most setups there’s no need to change them. If there’s a mandatory requirement, in Nginx 1.19.4 and later settings can be passed directly to OpenSSL with the ssl_conf_command Ciphersuites directive.