TLS Config Snippet Builder
Generate TLS configuration snippets for nginx/Apache
Web Server
Security Profile
Options
Certificate Paths
Configuration Snippet
# TLS Configuration ssl_certificate /etc/ssl/certs/server.crt; ssl_certificate_key /etc/ssl/private/server.key; # Protocols ssl_protocols TLSv1.2 TLSv1.3; # Cipher suites 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 on; # Session resumption ssl_session_timeout 1d; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; # OCSP Stapling ssl_stapling on; ssl_stapling_verify on; resolver 1.1.1.1 8.8.8.8 valid=300s; resolver_timeout 5s; # HSTS add_header Strict-Transport-Security 'max-age=63072000; includeSubDomains; preload' always;
Configuration Notes
- Based on Mozilla SSL Configuration Generator recommendations
- Modern profile requires clients with TLS 1.3 support
- Intermediate profile is recommended for most deployments
- Test your configuration with SSL Labs after deployment
The TLS Config Snippet Builder generates production-ready SSL/TLS configuration snippets for nginx, Apache, and other web servers, with correct cipher suites, protocol versions, HSTS headers, and OCSP stapling settings aligned to Mozilla's recommended security profiles. Select a server and a security profile, and get a complete configuration block you can deploy with confidence.
Understanding TLS Configuration
Getting TLS configuration right is one of the trickiest parts of web server administration. The protocol has evolved dramatically over the past decade: TLS 1.0 and 1.1 are now deprecated, dozens of cipher suites have been retired due to vulnerabilities, and new features like OCSP stapling and HTTP Strict Transport Security have become essential. A configuration that earned an A+ on SSL Labs five years ago might score a C today if it still allows TLS 1.0 or includes weak ciphers like RC4 or 3DES.
The challenge is that getting any single directive wrong can either break compatibility for legitimate users or leave your server vulnerable. Enable TLS 1.3 only and you lock out users on older Android devices. Include a CBC-mode cipher for compatibility and you might be exposed to padding oracle attacks if your implementation is not careful. Forget to set ssl_prefer_server_ciphers and clients might negotiate a weaker cipher than necessary. The permutations are complex enough that even experienced sysadmins copy configurations from blog posts, some of which are years out of date.
This builder eliminates that guesswork. It generates configurations based on Mozilla's SSL Configuration Generator recommendations, which are maintained by security engineers and updated as the threat landscape evolves. You choose a security profile -- Modern for maximum security, Intermediate for broad compatibility, or Legacy for systems that must support very old clients -- and the builder produces a complete, commented configuration block for your target server software. Every directive is explained so you understand what it does, not just how to paste it.
How to Generate a TLS Configuration Snippet
- Select your target web server (nginx, Apache, HAProxy, etc.)
- Choose a security profile: Modern, Intermediate, or Legacy
- Optionally set your certificate and key file paths
- Copy the generated configuration block into your server config
Security Profile Comparison
| Profile | Protocols | Oldest Compatible Client | Use Case |
|---|---|---|---|
| Modern | TLS 1.3 only | Chrome 70, Firefox 63, Safari 12.1 | New deployments without legacy client needs |
| Intermediate | TLS 1.2 + TLS 1.3 | Chrome 30, Firefox 27, IE 11 (Win 7+), Android 5.0 | Most production websites |
| Legacy | TLS 1.0 + TLS 1.1 + TLS 1.2 + TLS 1.3 | IE 8 (Win XP), Android 2.3 | Legacy systems, gradual migration |
Example Generated Configurations
nginx -- Intermediate Profile
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/ssl/certs/example.com-chain.pem;
ssl_certificate_key /etc/ssl/private/example.com.key;
# Protocols
ssl_protocols TLSv1.2 TLSv1.3;
# Cipher suites (intermediate compatibility)
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;
ssl_prefer_server_ciphers off;
# HSTS (1 year, including subdomains)
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# OCSP Stapling
ssl_stapling on;
ssl_stapling_verify on;
resolver 1.1.1.1 8.8.8.8 valid=300s;
resolver_timeout 5s;
# Session settings
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
}
Apache -- Modern Profile (TLS 1.3 Only)
<VirtualHost *:443>
ServerName example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/example.com.crt
SSLCertificateKeyFile /etc/ssl/private/example.com.key
SSLCertificateChainFile /etc/ssl/certs/chain.pem
# TLS 1.3 only
SSLProtocol -all +TLSv1.3
SSLOpenSSLConfCmd Curves X25519:secp256r1:secp384r1
# HSTS
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
# OCSP Stapling
SSLUseStapling On
SSLStaplingCache shmcb:/var/run/ocsp(128000)
</VirtualHost>
When to Use This Tool
- New HTTPS server setup -- generate a secure baseline configuration instead of copying outdated snippets from blog posts
- TLS hardening -- upgrade an existing configuration from weak cipher suites and old protocol versions to current best practices
- Security audit preparation -- generate configurations that will pass Qualys SSL Labs tests with an A+ rating
- Compliance requirements -- produce configurations meeting PCI DSS, HIPAA, or SOC 2 requirements for encryption in transit
- Learning TLS best practices -- each directive includes comments explaining its purpose, making the generated config educational
- Server migration -- generate equivalent configurations when migrating from Apache to nginx or vice versa
Key TLS Configuration Directives Explained
Cipher Suite Selection
Cipher suites define the algorithms used during the TLS handshake and data encryption:
| Component | Modern Choice | Purpose |
|---|---|---|
| Key exchange | ECDHE | Forward secrecy via ephemeral keys |
| Authentication | RSA or ECDSA | Server identity verification |
| Bulk cipher | AES-128-GCM, AES-256-GCM, CHACHA20-POLY1305 | Data encryption |
| MAC | AEAD (built into GCM/POLY1305) | Data integrity |
HSTS (HTTP Strict Transport Security)
The Strict-Transport-Security header tells browsers to always use HTTPS:
max-age=31536000-- remember for 1 year (31,536,000 seconds)includeSubDomains-- apply to all subdomainspreload-- opt in to browser HSTS preload lists (submit separately at hstspreload.org)
OCSP Stapling
Without stapling, browsers must contact the CA's OCSP responder to check certificate revocation, adding latency. With stapling enabled, the server fetches the OCSP response and includes it in the TLS handshake, improving performance and privacy.
Session Management
ssl_session_timeout 1d; # Sessions valid for 1 day
ssl_session_cache shared:SSL:10m; # 10 MB shared cache (~40,000 sessions)
ssl_session_tickets off; # Disable tickets (they break forward secrecy)
Session tickets are disabled in the recommended configurations because they use a single key that, if compromised, allows decryption of all sessions that used it. The shared session cache provides resumption without this risk.
TLS Configuration in Practice
The most important advice for TLS configuration is to start with the Intermediate profile and only deviate if you have a specific reason. The Intermediate profile supports TLS 1.2 and 1.3 with strong AEAD cipher suites, which covers every actively maintained browser and operating system. It is the right choice for the vast majority of public-facing websites. The Modern profile (TLS 1.3 only) is appropriate for internal APIs and services where you control the clients, but it will lock out users on older Android devices or corporate environments with outdated proxy servers.
After deploying your configuration, test it with Qualys SSL Labs (ssllabs.com/ssltest) to verify your server is correctly configured. An A+ rating requires HSTS with a max-age of at least 6 months and a clean TLS configuration with no weak protocols or ciphers. If you score lower, the report will tell you exactly what to fix -- typically a stray TLS 1.0 or a weak cipher suite that was left in the configuration from a previous version.
One frequently overlooked detail is OCSP stapling configuration. Without it, browsers need to make a separate request to the CA's OCSP server to check whether your certificate has been revoked, adding 100-300ms of latency to the first connection. With stapling, your server fetches the OCSP response itself and includes it in the TLS handshake, eliminating this delay. The configuration is straightforward but requires a working DNS resolver on your server -- if the resolver is misconfigured, stapling silently fails and connections fall back to the slower non-stapled path.
Frequently Asked Questions
Should I use the Modern or Intermediate profile? Use Intermediate for most production websites. It supports TLS 1.2 and 1.3, covering virtually all actively maintained browsers and operating systems. Use Modern (TLS 1.3 only) for internal services, APIs, or new deployments where you can confirm all clients support TLS 1.3. Avoid the Legacy profile unless you must support clients older than Windows 7 or Android 5.0.
Why should I disable TLS 1.0 and 1.1? TLS 1.0 and 1.1 have known vulnerabilities (BEAST, POODLE) and were formally deprecated by RFC 8996 in March 2021. Major browsers removed TLS 1.0/1.1 support in 2020. PCI DSS 3.2+ requires disabling TLS 1.0 for compliance. There is rarely a legitimate reason to keep these protocols enabled.
What does ssl_prefer_server_ciphers off mean?
With TLS 1.3, cipher preference is always determined by the server regardless of this setting. For TLS 1.2 with the Intermediate profile, setting this to off lets the client choose its preferred cipher, which works well because all ciphers in the recommended list are equally secure. The Modern profile omits this directive entirely.
How do I enable HSTS preloading?
HSTS preloading means your domain is hardcoded into browsers' HSTS lists, so the browser always uses HTTPS even on the very first visit. Add preload to your HSTS header: max-age=31536000; includeSubDomains; preload. Then submit your domain at hstspreload.org. Be careful: preloading is difficult to undo, and it applies to all subdomains, so ensure every subdomain supports HTTPS first.
Why are session tickets disabled in the recommended configuration? TLS session tickets use a symmetric key stored on the server. If this key is compromised or never rotated, an attacker can decrypt any recorded session that was resumed with a ticket. Disabling tickets and using the server-side session cache instead preserves forward secrecy. If you need tickets (e.g., for distributed servers without a shared cache), rotate the ticket key at least daily.
How do I test my TLS configuration after deployment?
Use Qualys SSL Labs at ssllabs.com/ssltest for a comprehensive analysis. For quick command-line checks, use openssl s_client -connect yourserver.com:443 to verify the protocol version and cipher negotiated. The nmap --script ssl-enum-ciphers -p 443 yourserver.com command lists all supported ciphers and protocols.
Related Tools
- PEM Bundle Merger - Build the certificate chain file referenced in the generated config
- Certificate Expiry Checker - Monitor the certificates used in your TLS configuration
- X.509 Certificate Viewer - Inspect the certificates before deploying with the generated config
- PEM Bundle Splitter - Split certificate bundles to prepare files for your server
- Convert DER to PEM - Convert certificates to PEM format required by nginx and Apache