How to fix SSL_ERROR_RX_RECORD_TOO_LONG on nginx

If curl reports “SSL_ERROR_RX_RECORD_TOO_LONG” after configuring nginx, the HTTP response protocol has been configured incorrectly.
“SSL_ERROR_RX_RECORD_TOO_LONG” means that the server returned plaintext HTTP content rather than encrypted HTTPS content.
How to fix it
- Check that listen is followed by ssl, as in this example.
listen 443 ssl;
- If listen is configured as above and the error remains, check whether:
ssl on;
is present. If so, remove it.