Disable old TLS versions (1.0/1.1 ) for Apache/Nginx on Ubuntu 18.04 or CentOS 7

Posted February 27, 2020 23.4k views
NginxCentOSApacheUbuntu 18.04

I recently got asked how we can disable old TLS versions on a server. The user was applying for a PCI compliance and wanted to have only TLS 1.2 running on their machine in order to pass the scan of the PCI vendor.


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers
  1. Here is a little step by step guide on how to set this on a CentOS server.

Before you start, please keep in mind that you can always run into some issues and it’s really important to make a working copy of your configuration files or to do a full server/droplet backup before you start the process. In this way you can always restore your config files or the whole droplet in case something goes wrong.

If you’re running Apache server you will need to tweak the Apache/httpd configuration file in order to disable TLS 1.0 and 1.1

One thing to keep on mind is that if you have any control panel interface/gui like cPanel/Plesk you must tweak the configuration file from the control panel or the changes will be reverted.

If you don’t have any control panel running on the server you can make the change manually in the httpd configuration file. The location of the file should be:


and you might have a symlink here:

  • this symlink is usually present when you’re running on a cPanel server

You can open the httpd configuration file with your favorite text editor, so you can use vi, vim or nano it’s totally up to you.

You need to locate the following lines/rows:


The first one is for the SSL Cipher Suite and the second one for the actual protocol. In order to set only TLS 1.2 to be active you can copy/paste the following lines:

SSLProtocol TLSv1.2

You can double check the available cipher suites using this link:

For TLS 1.3 you can use:

SSLProtocol TLSv1.2;

Now that server configured. It is time to test our apache config server for syntax errors:

sudo apache2 -t

Reload or restart the apache server:

sudo apache2 restart nginx


sudo service apache2 restart


  1. Here is a little step by step guide on how to set this on a Ubuntu server.

If you’re running a Ubuntu 18.04 server you should be able to tweak the Apache configuration by following this steps:

You can open the Apache config file using any text editor and then look for the following lines/rows:

The file should be located here:



In order to leave only TLS 1.2 active you can use the following:

SSLProtocol TLSv1.2

If you’re using Let’s Encrypt you need to edit the following file:


And put the following as code:

# This file contains important security parameters. If you modify this file
# manually, Certbot will be unable to automatically provide future security
# updates. Instead, Certbot will print and log an error message with a path to
# the up-to-date file that you will need to refer to when manually updating
# this file.

SSLEngine on

# Intermediate configuration, tweak to your needs
#SSLProtocol             all -SSLv2 -SSLv3
SSLProtocol +all -SSLv3 -TLSv1 -TLSv1.1
SSLHonorCipherOrder     on
SSLCompression          off

SSLOptions +StrictRequire

# Add vhost name to log entries:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vhost_combined
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common

#CustomLog /var/log/apache2/access.log vhost_combined
#LogLevel warn
#ErrorLog /var/log/apache2/error.log

# Always ensure Cookies have "Secure" set (JAH 2012/1)
#Header edit Set-Cookie (?i)^(.*)(;\s*secure)??((\s*;)?(.*)) "$1; Secure$3$4"

Now that server configured. It is time to test our apache config server for syntax errors:

sudo apache2 -t

Reload or restart the apache server:

sudo apache2 restart nginx


sudo service apache2 restart

This should make only TLS 1.2 availble.


  1. For tweaking the TLS configuration on Nginx () follow this:

Open the nginx configuration file:


Insert the following code snippet:

ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers off

Now that server configured. It is time to test our nginx config server for syntax errors:

nginx -t

Reload or restart the nginx server:

sudo systemctl restart nginx


sudo service nginx restart

In order to test if everything is okay and only TLS 1.2 is available you can use either nmap or openssl

Example namp command:

nmap --script ssl-enum-ciphers -p 443 IPaddress/Hostname

Example openssl command:

openssl s_client -connect domain:443 -tls1_2

Hope this helps!

Please feel free to comment bellow if you use a different way/method to configure this!


May also need to edit /etc/letsencrypt/options-ssl-nginx.conf (apart from /etc/nginx/nginx.conf) per

by Hazel Virdó
by Kathleen Juell
In this tutorial, we will show you how to use Let's Encrypt to obtain a free SSL certificate and use it with Nginx on Ubuntu 18.04. We will also show you how to automatically renew your SSL certificate. If you're running a different web server, simply follow your web server's documentation to learn how to use the certificate with your setup.