Amazon holiday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Configure Nginx to Use TLS 1.2 and 1.3 Only

Ensuring your web server uses only specific versions of TLS enhances security by preventing the use of outdated or vulnerable protocols. Limiting Nginx to TLS 1.2 and 1.3 helps protect data in transit and aligns with modern security standards. Before you begin, make sure you have administrative access to your server, a working installation of Nginx, and a valid SSL certificate (either self-signed or from a trusted CA). This guide walks you through configuring Nginx to accept only TLS 1.2 and TLS 1.3, ensuring your website communicates securely using these protocols exclusively.

What You’ll Need

  • Root or sudo access to your server
  • Installed Nginx web server
  • Valid SSL/TLS certificate and private key
  • Text editor (e.g., nano, vim)

Step-by-Step

  1. Backup your current Nginx configuration to prevent data loss:
    sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
  2. Locate your SSL configuration block within your server block. Typically, it’s in sites-available or directly in /etc/nginx/nginx.conf. Open your site configuration file with a text editor:
    sudo nano /etc/nginx/sites-available/your_site
  3. Find the ssl_protocols directive. If it doesn’t exist, add it within the server block that handles SSL. Set it to only allow TLS 1.2 and TLS 1.3:
    ssl_protocols TLSv1.2 TLSv1.3;
  4. Ensure the rest of your SSL settings are properly configured for security. For example, include strong cipher suites and other recommended SSL parameters:
  5. ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;
  6. Save your changes and exit the editor. For nano, press CTRL+O, Enter, then CTRL+X.
  7. Test your Nginx configuration for syntax errors:
    sudo nginx -t. If errors are found, fix them before proceeding.
  8. Reload Nginx to apply the new settings:
    sudo systemctl reload nginx
  9. Verify your server is now only accepting TLS 1.2 and 1.3 connections using online tools such as SSL Labs’ SSL Server Test or command-line tools like openssl:
    openssl s_client -connect yourdomain.com:443 -tls1_2 and
    openssl s_client -connect yourdomain.com:443 -tls1_3. Ensure the connection succeeds and no other protocols are accepted.

Common Mistakes

  • Not restarting or reloading Nginx after making configuration changes.
  • Forgetting to include the ssl_protocols directive or setting it incorrectly.
  • Using incompatible cipher suites that do not support TLS 1.2 or 1.3.
  • Applying configuration changes to the wrong server block or file.
  • Not testing the configuration before reloading, leading to server downtime.

Tips

  • Always back up your configuration files before making significant changes.
  • Use online SSL testing tools to verify your server’s protocol support after configuration.
  • Keep your Nginx and OpenSSL versions up to date to support the latest TLS features and security patches.
  • Combine ssl_protocols with strong cipher suites for optimal security.
  • Consider enabling HTTP/3 if supported, as it also uses TLS 1.3 by default.

Troubleshooting

If your server is not accepting only TLS 1.2 and 1.3 as intended, follow these steps:

  1. Recheck your configuration syntax with nginx -t. Any errors must be fixed before reloading.
  2. Ensure you’ve correctly set ssl_protocols TLSv1.2 TLSv1.3; in the right server block.
  3. Verify that no other configuration files override your settings. Sometimes, include files or global configs may conflict.
  4. Test with openssl commands to confirm which protocols are accepted. For example:
    openssl s_client -connect yourdomain.com:443 -tls1_2 should succeed, while
    openssl s_client -connect yourdomain.com:443 -tls1_3 should also succeed if correctly configured.
  5. If older protocols still seem to be accepted, restart your server completely:
    sudo systemctl restart nginx.
  6. Check your browser’s developer tools or SSL testing services for detailed protocol support reports.

Frequently Asked Questions

Can I enable only TLS 1.3?

Yes, set ssl_protocols TLSv1.3;. However, ensure all clients support TLS 1.3, as older browsers may fail to connect.

Why should I disable older TLS versions?

Older versions like TLS 1.0 and 1.1 have known security vulnerabilities. Disabling them reduces exposure to attacks.

Will this affect my website’s compatibility?

It might, especially for legacy browsers or systems. Test your site with various clients before enforcing strict protocols.

How do I verify the protocols supported after configuration?

Use SSL Labs’ SSL Server Test or command-line tools like openssl s_client to check supported protocols.

Can I configure different protocols for different sites?

Yes, by editing each server block individually, you can set specific ssl_protocols directives per site.

Is it safe to use self-signed certificates with this setup?

While self-signed certificates work for testing, for production, use certificates from a trusted CA to ensure trust and security.

Configure Nginx to Use TLS 1.2 and 1.3 Only
Scroll to top