Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

nginx warns that 'ssl on' is deprecated, or serves plain HTTP on 443

Errornginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead

Short answer

The ssl directive was made obsolete in nginx 1.15.0 and removed in 1.25.1. Delete 'ssl on;' and add the ssl parameter to the listen line instead: listen 443 ssl;. If you delete the line and leave listen 443 without ssl, nginx answers on that port without TLS.

  • Applies to nginx 1.26, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find every place the old directive is used, including included files.

    grep -R -n -E "^\s*ssl\s+on" /etc/nginx/
  2. 2Match what you see, then jump to its fix

    1. 1The warning names the file and line of 'ssl on;'. On nginx 1.25.1 or later the directive no longer exists, so the check fails instead of warning.The config still contains the old ssl on directiveFix
    2. 2nginx -t passes, yet https://example.com fails and the port answers in plain HTTP.ssl on was removed but the listen line has no ssl parameterFix

What does the error look like?

  • nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead
  • nginx -t fails after an upgrade to 1.25.1 or later, at the line that contains ssl on;

Cause 1 of 2

The config still contains the old ssl on directive

1Check

Look at the server block that holds the line and at its listen directive.

sudo nginx -T 2>&1 | grep -n -E "listen|ssl on"

2Fix

Remove 'ssl on;' and put the ssl parameter on the listen directive of the same server block.

server {
    listen 443 ssl;
    server_name example.com;
    ssl_certificate     /etc/nginx/ssl/example.com.crt;
    ssl_certificate_key /etc/nginx/ssl/example.com.key;
}

3Verify

The syntax test passes without the warning.

sudo nginx -t

Confirmed by nginx.org

Did this fix it?

Cause 2 of 2

ssl on was removed but the listen line has no ssl parameter

1Check

Print the listen directives. TLS is enabled per listening socket, so a bare 'listen 443;' has none.

grep -R -n "listen" /etc/nginx/sites-enabled/

2Fix

Add ssl to each listen line that must serve HTTPS. For IPv6, repeat it on the second line.

listen 443 ssl;
listen [::]:443 ssl;

3Verify

Reload and check that the handshake works.

sudo nginx -t && sudo systemctl reload nginx
curl -I https://example.com

Confirmed by nginx.org

Did this fix it?

How do I stop it coming back?

  • After every nginx upgrade run nginx -t before reloading, and read the warnings, not only the final line.
  • Keep one listen line per port and address, each with its own ssl parameter.
  • Remove copied snippets from old tutorials that start with ssl on.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.