Skip to content

How to Configure SSL/TLS in Nginx

DodaTech Updated 2026-06-24 1 min read

SSL/TLS configuration in Nginx secures HTTPS connections. Modern settings with TLS 1.2/1.3 and AEAD ciphers provide strong security. This guide walks through the specific troubleshooting steps to diagnose and resolve SSL configuration issues.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

listen 443;\nssl on;\nssl_certificate cert.pem;

Wrong: Deprecated ssl on syntax with weak protocol support

listen 443 ssl http2;\nssl_certificate /etc/ssl/certs/fullchain.pem;\nssl_certificate_key /etc/ssl/private/privkey.pem;\nssl_protocols TLSv1.2 TLSv1.3;\nssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;\nssl_prefer_server_ciphers on;

Right: Modern SSL with ssl parameter, http2, and strong ciphers

Output

HTTPS configured with TLS 1.2 and 1.3\nSSL session cache: 10MB shared\nHTTP/2 enabled

Prevention

To avoid future issues, follow these best practices:

  • Use listen 443 ssl http2 instead of deprecated ssl on directive
  • Enable only TLS 1.2 and TLS 1.3
  • Use a strong cipher list with AEAD ciphers only
  • Set ssl_session_cache shared:SSL:10m for performance
  • Set ssl_session_tickets off for better forward secrecy

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with ssl config

  1. Using foldl instead of foldl' causing stack overflow on large lists
  2. Forgetting deriving (Show, Eq) on custom data types needed for debugging
  3. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable

These mistakes appear frequently in real-world NGINX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

What is the correct way to enable SSL in Nginx?|||Add the ssl parameter to the listen directive: listen 443 ssl;. Do not use the deprecated ssl on; directive.
How do I redirect HTTP to HTTPS? Add a server block listening on port 80 with return 301 https://$host$request_uri;.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro