Tutorial

How To Install an SSL Certificate from a Commercial Certificate Authority

Updated on December 2, 2022
How To Install an SSL Certificate from a Commercial Certificate Authority

Introduction

This tutorial will show you how to acquire and install an SSL certificate from a trusted, commercial Certificate Authority (CA). SSL certificates allow web servers to encrypt their traffic, and also offer a mechanism to validate server identities to their visitors. Websites using SSL are accessed via the https:// protocol.

Before the mid-2010s, many smaller websites did not always use SSL or HTTPS. Since then, expectations of security have increased, and the Let’s Encrypt project was created to provide free, trusted SSL certificates at scale, allowing almost everyone to use HTTPS as needed.

However, there are some limitations to Let’s Encrypt’s certificates. They expire every 3 months, typically requiring you to have a functioning auto-renewal script in place, and can be awkward to use in environments where this is not possible. Let’s Encrypt also does not provide Extended Validation certificates which validate the legal ownership of your web presence, or Wildcard Certificates that will automatically match every possible subdomain of your website (such as shop.example.com) without you having to register each of them manually.

For most users, these will not be significant limitations. Let’s Encrypt is a popular option for many personal and commercial websites. However, if you have particular enterprise software requirements, or a very large commercial operation, you should consider purchasing a certificate from a commercial CA.

This tutorial covers how to select and deploy an SSL certificate from a trusted certificate authority. After you have acquired your SSL certificate, this tutorial will cover installing it on the Nginx and Apache web servers.

Prerequisites

There are several prerequisites to attempting to obtain an SSL certificate from a commercial CA:

  • A registered domain name. This tutorial will use example.com throughout. You can purchase a domain name from Namecheap, get one for free with Freenom, or use the domain registrar of your choice.

  • Access to one of the email addresses on your domain’s WHOIS record or to an “admin type” email address at the domain itself. Certificate authorities that issue SSL certificates will typically validate domain control by sending a validation email to one of the addresses on the domain’s WHOIS record, or to a generic admin email address at the domain itself. To be issued an Extended Validation certificate, you will also be required to provide the CA with paperwork to establish the legal identity of the website’s owner, among other things.

  • DNS records set up for your server. If you are using DigitalOcean, please see our DNS documentation for details on how to add them.

This tutorial will provide configuration instructions for a Ubuntu 22.04 server set up by following this initial server setup for Ubuntu 22.04 tutorial, including a sudo-enabled non-root user and a firewall. Most modern Linux flavors will work similarly.

You should also have a web server like Nginx or Apache installed, following How To Install Nginx on Ubuntu 22.04 or How To Install the Apache Web Server on Ubuntu 22.04. Be sure that you have a server block (or Apache virtual host) for your domain.

Step 1 – Choosing Your Certificate Authority

If you are not sure which Certificate Authority to use, there are a few factors to consider.

Root Certificate Program Memberships

The most crucial point is that the CA that you choose is a member of the root certificate programs of the most commonly used operating systems and web browsers, i.e. it is a “trusted” CA, and its root certificate is trusted by common browsers and other software. If your website’s SSL certificate is signed by a trusted CA, its identity is considered to be valid by software that trusts the CA.

Most commercial CAs that you will encounter will be members of the common root CA programs, but it does not hurt to check before making your certificate purchase. For example, Apple publishes its list of trusted SSL root certificates.

Certificate Types

Ensure that you choose a CA that offers the certificate type that you require. Many CAs offer variations of these certificate types under a variety of names and pricing structures. Here is a short description of each type:

  • Single Domain: Used for a single domain, e.g. example.com. Note that additional subdomains, such as www.example.com, are not included
  • Wildcard: Used for a domain and any of its subdomains. For example, a wildcard certificate for *.example.com can also be used for www.example.com and store.example.com
  • Multiple Domain: Known as a SAN or UC certificate, these can be used with multiple domains and subdomains that are added to the Subject Alternative Name field. For example, a single multi-domain certificate could be used with example.com, www.example.com, and example.net

In addition to the aforementioned certificate types, there are different levels of validations that CAs offer:

  • Domain Validation (DV): DV certificates are issued after the CA validates that the requestor owns or controls the domain in question
  • Organization Validation (OV): OV certificates can be issued only after the issuing CA validates the legal identity of the requestor
  • Extended Validation (EV): EV certificates can be issued only after the issuing CA validates the legal identity, among other things, of the requestor, according to a strict set of guidelines. The purpose of this type of certificate is to provide additional assurance of the legitimacy of your organization’s identity to your site’s visitors. EV certificates can be single or multiple domain, but not wildcard

Additional Features

Many CAs offer a large variety of “bonus” features to differentiate themselves from the rest of the SSL certificate-issuing vendors. Some of these features can end up saving you money, so it is important that you weigh your needs against the offerings before making a purchase. Example of features to look out for include free certificate reissues or a single domain-priced certificate that works for www. and the domain basename, e.g. www.example.com with a SAN of example.com

Step 2 – Generating a CSR and Private Key

After you have your prerequisites sorted, and you know the type of certificate you need, it’s time to generate a certificate signing request (CSR) and private key.

If you are planning on using Apache HTTP or Nginx as your web server, you can use the openssl command to generate your private key and CSR on your web server. In this tutorial, you can keep all of the relevant files in your home directory, but feel free to store them in any secure location on your server:

To generate a private key, called example.com.key, and a CSR, called example.com.csr, run this command (replace the example.com with the name of your domain):

  1. openssl req -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr

At this point, you will be prompted for several lines of information that will be included in your certificate request. The most important part is the Common Name field, which should match the name that you want to use your certificate with – for example, example.com, www.example.com, or (for a wildcard certificate request) *.example.com. If you are planning on getting an OV or EV certificate, ensure that all of the other fields accurately reflect your organization or business details. Providing a “challenge password” is not necessary.

For example:

Output
Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:New York Locality Name (eg, city) []:New York Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company Organizational Unit Name (eg, section) []: Common Name (e.g. server FQDN or YOUR name) []:example.com Email Address []:sammy@example.com Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:

This will generate a .key and .csr file. The .key file is your private key, and should be kept secure. The .csr file is what you will send to the CA to request your SSL certificate.

  1. ls example.com*
Output
example.com.csr example.com.key

You will need to copy and paste your CSR when submitting your certificate request to your CA. To print the contents of your CSR, use cat:

cat example.com.csr

Now you are ready to buy a certificate from a CA.

Step 3 – Purchasing and Obtaining a Certificate

There are many commercial CA providers, and you can compare and contrast the most appropriate options for your own setup. For example, Namecheap acts as an SSL certificate reseller, and has changed upstream CA providers in the past to provide the best value. Currently, they offer certificates from Comodo CA. Here is a sample of their offerings as of December 2022:

Namecheap SSL Offerings

After making a selection, you will need to upload the CSR that you generated in the previous step. Your CA provider will also likely have an “Approver” step, which will send a validation request email to an address in your domain’s WHOIS record or to an administrator type address of the domain that you are getting a certificate for.

After approving the certificate, the certificate will be emailed to the named administrator. Copy and save them to your server in the same location that you generated your private key and CSR. Name the certificate with the domain name and a .crt extension, e.g. example.com.crt, and name the intermediate certificate intermediate.crt.

The certificate is now ready to be installed on your web server, but first, you may have to make some changes to your firewall.

Step 4 – Updating your Firewall to Allow HTTPS

If you have the ufw firewall enabled as recommended by our Ubuntu 22.04 setup guide, you’ll need to adjust the settings to allow for HTTPS traffic. Nginx and Apache both register a few profiles with ufw upon installation.

You can see the current setting by typing:

  1. sudo ufw status

If you receive output containing just Nginx HTTP or Apache, only HTTP traffic is allowed to the web server:

Output
Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere Nginx HTTP ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Nginx HTTP (v6) ALLOW Anywhere (v6)

To additionally let in HTTPS traffic, allow the Nginx Full or Apache Full` profile and delete the redundant HTTP profile allowance:

  1. sudo ufw allow 'Nginx Full'
  2. sudo ufw delete allow 'Nginx HTTP'

That should produce a result like this:

  1. sudo ufw status
Output
Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere Nginx Full ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Nginx Full (v6) ALLOW Anywhere (v6)

In the final step, you’ll install the certificate.

Step 5 – Installing a Certificate On Your Server

After acquiring your certificate from the CA of your choice, you need to install it on your web server. This involves adding a few SSL-related lines to your web server software configuration.

This tutorial will cover configuring Nginx and Apache on Ubuntu 22.04, but most modern Linux flavors will work similarly. This tutorial also makes these assumptions:

  • The private key, SSL certificate, and, if applicable, the CA’s intermediate certificates are located in a home directory, at /home/sammy
  • The private key is called example.com.key
  • The SSL certificate is called example.com.crt
  • The CA intermediate certificate(s) returned by your provider are in a file called intermediate.crt

Note: In a production environment, these files should be stored somewhere that only the web server process (usually root) can access, and the private key should be kept secure. For example, Let’s Encrypt stores the certificates it generates in /etc/letsencrypt. Production examples will vary due to the complexity of multi-server configurations.

Nginx

These are the steps to manually deploy an SSL certificate on Nginx.

If your CA returned only an intermediate certificate, you must create a single “chained” certificate file that contains your certificate and the CA’s intermediate certificates.

Assuming your certificate file is called example.com.crt, you can use the cat command to append files together to create a combined file called example.com.chained.crt:

  1. cat example.com.crt intermediate.crt > example.com.chained.crt

Using nano or your favorite text editor, open your default Nginx server block file for editing:

  1. sudo nano /etc/nginx/sites-enabled/default

Find the listen directive, and modify it to listen 443 ssl:

/etc/nginx/sites-enabled/default
…
server {
    listen 443 ssl;
…

Next, find the server_name directive within that same server block, and make sure that its value matches the common name of your certificate. Also, add the ssl_certificate and ssl_certificate_key directives to specify the paths of your certificate and private key files:

/etc/nginx/sites-enabled/default
…
    server_name example.com;
    ssl_certificate /home/sammy/example.com.chained.crt;
    ssl_certificate_key /home/sammy/example.com.key;
…

To allow only the most secure SSL protocols and ciphers, add the following lines to the file:

/etc/nginx/sites-enabled/default
…
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
…

Finally, to redirect HTTP requests to HTTPS by default, you can add an additional server block at the top of the file:

/etc/nginx/sites-enabled/default
server {
    listen 80;
    server_name example.com;
    rewrite ^/(.*) https://example.com/$1 permanent;
}
…

Save and close the file. If you are using nano, press Ctrl+X, then when prompted, Y and then Enter.

Before restarting Nginx, you can validate your configuration by using nginx -t:

  1. sudo nginx -t

If there aren’t any problems, restart Nginx to enable SSL over HTTPS:

  1. sudo systemctl restart nginx

Test it out by accessing your site via HTTPS, e.g. https://example.com. You will also want to try connecting via HTTP, e.g. http://example.com to ensure that the redirect is working properly.

Apache

These are the steps to manually deploy an SSL certificate on Apache.

Using nano or your favorite text editor, open your default Apache virtual host file for editing:

  1. sudo nano /etc/apache2/sites-available/000-default.conf

Find the <VirtualHost *:80> entry and modify it so your web server will listen on port 443:

/etc/apache2/sites-available/000-default.conf
…
<VirtualHost *:443>
…

Next, add the ServerName directive, if it doesn’t already exist:

/etc/apache2/sites-available/000-default.conf
…
ServerName example.com

Then add the following lines to specify your certificate and key paths:

/etc/apache2/sites-available/000-default.conf
…
SSLEngine on
SSLCertificateFile /home/sammy/example.com.crt
SSLCertificateKeyFile /home/sammy/example.com.key
SSLCACertificateFile /home/sammy/intermediate.crt

At this point, your server is configured to listen on HTTPS only (port 443), so requests to HTTP (port 80) will not be served. To redirect HTTP requests to HTTPS, add the following to the top of the file (substitute the name in both places):

/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
   ServerName example.com
   Redirect permanent / https://example.com/
</VirtualHost>
…

Save and close the file. If you are using nano, press Ctrl+X, then when prompted, Y and then Enter.

Enable the Apache SSL module by running this command:

  1. sudo a2enmod ssl

Now, restart Apache to load the new configuration and enable TLS/SSL over HTTPS.

  1. sudo systemctl restart apache2

Test it out by accessing your site via HTTPS, e.g. https://example.com. You will also want to try connecting via HTTP, e.g. http://example.com to ensure that the redirect is working properly.

Conclusion

In this tutorial, you learned how to determine when you might need to purchase an SSL certificate from a commercial CA, and how to compare and contrast the available options. You also learned how to configure Nginx or Apache for HTTPS support, and how to adapt their configurations for production.

Next, you may want to read about other SSL use cases, such as when working with load balancers.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Default avatar

Senior DevOps Technical Writer


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
50 Comments
Leave a comment...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Hi, when I try and run:

$ openssl req -newkey rsa:2048 -nodes -keyout mydomain.com.key -out mydomain.com.csr

I get:

WARNING: can’t open config file: /usr/lib/ssl/openssl.cnf Unable to load config info from /usr/lib/ssl/openssl.cnf

Please help!

alexdo
Site Moderator
Site Moderator badge
October 30, 2024

The error indicates that OpenSSL can’t find its configuration file (openssl.cnf). Here’s how to fix this:

  1. Locate the openssl.cnf File: On some systems, openssl.cnf might be located elsewhere, like /etc/ssl/openssl.cnf. Run this command to locate it:
find / -name openssl.cnf 2>/dev/null

If it exists in a different location, use that path with OpenSSL.

  1. Create a Symlink if Necessary: If openssl.cnf exists in another location, you can create a symlink to where OpenSSL expects it:
sudo ln -s /etc/ssl/openssl.cnf /usr/lib/ssl/openssl.cnf
  1. Specify the Config File Directly: You can also specify the path to openssl.cnf in the command itself:
openssl req -newkey rsa:2048 -nodes -keyout mydomain.com.key -out mydomain.com.csr -config /etc/ssl/openssl.cnf

If openssl.cnf is missing altogether, reinstalling OpenSSL should replace it:

sudo apt-get install --reinstall openssl

These steps should resolve the issue with the missing configuration file.

Regards

I am now unable to access the domain without HTTPS, is there a way to fix this?

Great guide btw.

Thanks

What Web Server are you using?

This comment has been deleted

    nginx, I solved it by adding an additional server directive.

    server {
        listen      80;
    
        location / {
          rewrite     ^(.*)   https://mysite.com$1 permanent;
        }
    

    Here’s the link to the stack page: http://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-http-requests-to-https-while-maintaining-sub-dom

    I’d recommend adding this to the guide as it it’s a PITA if it only accepts https and does not force a re-direct.

    Mitchell Anicas
    DigitalOcean Employee
    DigitalOcean Employee badge
    December 1, 2014

    That’s already in the guide, by the way.

    In my opinion the tutorial should onclude compatbility with a non-ssl version of the web.

    When I run the following setup

    root@example:/etc/ssl/nginx# cat www.example.com.crt intermediate.crt > www.example.com.chained.crt<^>
    

    I receive the following response

    -bash: syntax error near unexpected token `newline'
    

    Any ideas? I’m trying to chain a GoDaddy EV SSL, which I downloaded as Apache server type.

    Removed the <^> from the command, and it appears to have worked correctly now.

    Andrew SB
    DigitalOcean Employee
    DigitalOcean Employee badge
    December 11, 2014

    Looks like that was actually just a typo in the article. I’ve fixed it above. Thanks!

    This comment has been deleted

      My site is coming up as internal server error (https://rynopower.com/) Even though the SSL appears to be working. (Green lock is showing) Using PositiveSSL from Namecheap. SSL checking: https://www.sslchecker.com/sslchecker

      Running off of the Wordpress Ubuntu 14.04 Image.

      Created the ca-bundle with the four files provided by Namecheap:

      cat rynopower_com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt AddTrustExternalCARoot.crt > rynopower.ca-bundle

      All files are currently in /etc/ssl/

      CSR and Key that was generated are in the same folder currently.

      Relevant lines for default-ssl.conf:

      <IfModule mod_ssl.c> <VirtualHost default:443> ServerAdmin webmaster@localhost ServerName rynopower.com:443 SSLEngine on SSLCertificateFile /etc/ssl/rynopower_com.crt SSLCertificateKeyFile /etc/ssl/rynopower.key SSLCertificateChainFile /etc/ssl/rynopower.ca-bundle

      Any idea why my site wouldn’t work on https? It still works fine on http, and the lock comes up for https, just no content

      Mitchell Anicas
      DigitalOcean Employee
      DigitalOcean Employee badge
      December 17, 2014

      Is the rest of your default-ssl.conf correct?

      I don’t see anything in particularly wrong. But maybe you might.

      Here is the full file.

      http://pastebin.com/ERz5ppr7

      When trying to restart I get this:

      Output of config test was: AH00526: Syntax error on line 34 of /etc/apache2/sites-enabled/default-ssl.conf: SSLCertificateFile: file ‘/etc/apache2/ssl/certs/teampunt.co.uk.crt’ does not exist or is empty Action ‘configtest’ failed. The Apache error log may have more information.

      does anyone know why? I bought the cert from godaddy

      alexdo
      Site Moderator
      Site Moderator badge
      October 30, 2024

      The error message indicates that Apache is unable to find or access the SSL certificate file specified in your configuration. Here’s how to troubleshoot:

      1. Check Certificate Path: Verify that the certificate file exists at the specified location (/etc/apache2/ssl/certs/teampunt.co.uk.crt). Run:
      ls -l /etc/apache2/ssl/certs/teampunt.co.uk.crt
      

      If the file is not there or the path is incorrect, update the path in your configuration file (default-ssl.conf).

      1. Ensure File Permissions: Make sure Apache has permission to read the certificate file. Set appropriate permissions:
      sudo chmod 644 /etc/apache2/ssl/certs/teampunt.co.uk.crt sudo chown root:root /etc/apache2/ssl/certs/teampunt.co.uk.crt
      
      1. Re-download or Reinstall the Certificate: Sometimes, certificate files are empty if there was an issue with the download. You can re-download the certificate from your GoDaddy account and replace the existing one.

      2. Update Apache Configuration: Confirm that the certificate path in your default-ssl.conf file matches the location of the actual certificate. The configuration should look like this:

      SSLCertificateFile /etc/apache2/ssl/certs/teampunt.co.uk.crt
      SSLCertificateKeyFile /etc/apache2/ssl/private/teampunt.co.uk.key
      SSLCertificateChainFile /etc/apache2/ssl/certs/teampunt.co.uk.chain.pem  # Optional, if required
      
      1. Run Config Test Again: After verifying the path and permissions, rerun the Apache configuration test to ensure there are no errors:
      sudo apachectl configtest
      
      1. Restart Apache: If the config test passes, restart Apache:
      sudo systemctl restart apache2
      

      Regards

      HI there, thank you for this great article… when my ssl-provider issued my ssl certification i got with the certification two more files, first : COMODORSAAddTrustCA, second : COMODORSADomainValidationSecureServerCA

      but in your article you did’t mention anything about those more certifications, so can you give me some explanation about those more certifications ? where would i use them ?

      Best regards

      Mitchell Anicas
      DigitalOcean Employee
      DigitalOcean Employee badge
      January 6, 2015

      Are you using Nginx? If so, you will want to combine the files into the “chained” certificate file in a particular order:

      1. example.com.crt
      2. COMODORSADomainValidationSecureServerCA.crt
      3. COMODORSAAddTrustCA.crt
      4. AddTrustExternalCARoot.crt

      Or you can run this command to do the same thing (substitute the name of your certificate):

      cat example.com.crt COMODORSADomainValidationSecureServerCA.crt COMODORSAAddTrustCA.crt  AddTrustExternalCARoot.crt > example.com.chained.crt
      

      This was the correct order for me for cert from COMODO, though the exact file names vary slightly.

      This comment has been deleted

        What about apache ?

        Did you figure this out for apache?

        Any help would be appreciated.

        Mitchell Anicas
        DigitalOcean Employee
        DigitalOcean Employee badge
        April 21, 2015

        Place the intermediate certificates into intermediate.crt, then follow the instructions in the Apache section of this tutorial.

        “free StartSSL certificates are not trusted by some browsers”.

        Hmm, do you have any evidence of that? I’m getting an A+ rating from the Qualisys test with a free StartSSL certificate, and I’ve never heard of any current browser rejected a startSSL certificate.

        Might also be worth mentioning Cloudflare’s free Universal SSL offering, which “hides” a free server-signed key behind a “valid” key for “end to end” SSL, or even offers to make ANY website SSL, without a server-side certificate needed. https://blog.cloudflare.com/introducing-universal-ssl/

        There are some evidence. Have you ever heard of CACert? They offer free SSL certificates under their own root - not all major browsers support it though (not in their trust store/storage).

        Thanks for help

        gdd

        Thank you for your guide I managed to work but I changed the directory of the ssl files and now y cannot make it work. I have 2 domains tilabmx.com (default) and dianamejia.tk on LEMP with ubuntu 14.04. When I enter to tilabmx.com the server shows me dianamejia.tk (before setting up SSL everything was working fine) My conf file is: server { listen 443 ssl default_server; listen [::]:443 default_server ipv6only=on;

            root /var/www/tilabmx.com/html;
            index index.php index.html index.htm;
        
            # Make site accessible from http://localhost/
            server_name tilabmx.com www.tilabmx.com;
            rewrite ^/(.*) https://tilabmx.com/$1 permanent;
            ssl_certificate /home/stiuvert0007/tilabmx.com.chained.crt;
            ssl_certificate_key /home/stiuvert0007/tilabmx.com.key;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_prefer_server_ciphers on;
            ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
        

        }

        any idea? Thank you in advance!

        Mitchell Anicas
        DigitalOcean Employee
        DigitalOcean Employee badge
        January 23, 2015

        Check the Nginx error log (/var/log/nginx/error.log). It probably has to do with permissions of the files and their containing directories.

        Thank you very much for your answer! What are the appropiate permissions? When I run “sudo cat /var/log/nginx/error.log” nothing opens, like if there is no file

        Mitchell Anicas
        DigitalOcean Employee
        DigitalOcean Employee badge
        January 26, 2015

        Regarding the permissions, the SSL certs and keys need to be readable by the user that is starting the Nginx master process. It sounds like Nginx isn’t reporting any errors, so that is probably not the issue.

        Are you accessing your site with https instead of http?

        You probably delete rewrite ^/(.*) https://tilabmx.com/$1 permanent;

        Then add this to the top of your config file (if you want http to redirect to https):

        server {
            listen 80;
            server_name tilabmx.com;
            rewrite ^/(.*) https://tilabmx.com/$1 permanent;
        }
        

        Again thank you manicas! And sorry for all the questions. I really appreciate your help. Finally it’s working! My conf file is as follows:

        server {
                listen 80 default_server;
                listen [::]:80 default_server ipv6only=on;
        
                root /var/www/tilabmx.com/html;
                index index.php index.html index.htm;
        
                server_name tilabmx.com www.tilabmx.com;
                rewrite ^/(.*) https://tilabmx.com/$1 permanent;
        }
        
        

        after that I added

        server {
                listen 443;
                server_name tilabmx.com www.tilabmx.com;
        
                root /var/www/tilabmx.com/html;
                index index.php index.html index.htm;
        
                ssl on;
                ssl_certificate /home/stiuvert0007/tilabmx.com.chained.crt;
                ssl_certificate_key /home/stiuvert0007/tilabmx.com.key;
        
                ssl_session_timeout 5m;
        
                ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        #      ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; **<<<This is the default ssl_ciphers value. Is there any diference between this and the recommended in this tutorial?**
                ssl_prefer_server_ciphers on;
                ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL;
        
                location / {
                        try_files $uri $uri/ =404;
                }
        }
        

        I don’t know why if I put everything in the same server block it doesn’t work.

        alexdo
        Site Moderator
        Site Moderator badge
        September 30, 2024

        Regarding your setup, it’s typical to use separate server blocks for HTTP (port 80) and HTTPS (port 443) because they handle traffic differently. The HTTP block uses the rewrite directive to redirect traffic to HTTPS, while the HTTPS block manages secure connections. Combining them into one block often doesn’t work due to these differences.

        As for your SSL cipher configuration, you’re using AES256+EECDH:AES256+EDH:!aNULL, which is strong and modern, focusing on forward secrecy. The default setting (HIGH:!aNULL:!MD5:!3DES) is broader and includes more ciphers for compatibility but disables weak ones. Your setup prioritizes stronger encryption, though it might limit compatibility with older clients.

        The separation of blocks is necessary because NGINX processes HTTP and HTTPS differently, and keeping them apart ensures smooth handling of both protocols.

        You can also test your SSL configuration for security and compatibility using tools like SSL Labs.

        I think you forgot mention that we have to put SSLEngine on statement inside Apache config file. It didn’t work for me unless I added that on Apache v2.4.7.

        +1 for this.

        Need SSLEngine on for Apache v2.4.7

        Mitchell Anicas
        DigitalOcean Employee
        DigitalOcean Employee badge
        February 23, 2015

        Thanks! Updated.

        alexdo
        Site Moderator
        Site Moderator badge
        September 30, 2024

        Yes, adding SSLEngine on in the Apache configuration is crucial for enabling SSL. Without this directive, Apache won’t handle SSL connections even if you have everything else configured properly. It’s easy to overlook, but it’s a vital part of enabling HTTPS on your server. Glad you caught that!

        Very comprehensive guide, thanks.

        One command that helped me debug was:

        sudo nginx -t 
        

        That tests your config to make sure it is valid and will report any errors.

        alexdo
        Site Moderator
        Site Moderator badge
        September 28, 2024

        This is a valid point. You can always check the syntax of your Apache or Nginx config using the same command, difference will be the service name nginx -t or apachectl -t / apachectl configtest

        Regards

        I am at the end of it but cannot run SSLCACertificateFile /home/abc/intermediate.crt and SSLCertificateChainFile /home/abc/intermediate.crt. both returns command not found error on Ubuntu 14.04 with apache 2.4.7.

        Mitchell Anicas
        DigitalOcean Employee
        DigitalOcean Employee badge
        March 3, 2015

        Those aren’t commands that you should run. Add those to Apache configuration file.

        This comment has been deleted

          Hello , am not able to redirect http to https . Am using apache2 . Could you please verify .

          alexdo
          Site Moderator
          Site Moderator badge
          October 30, 2024

          To redirect HTTP to HTTPS in Apache, you can follow tho methods:

          1. Edit the HTTP Virtual Host: Open your site’s HTTP virtual host configuration file, usually located in /etc/apache2/sites-available/

          2. Using .htaccess for HTTP to HTTPS redirects is also effective, especially if you prefer to manage redirects at a directory level rather than in the main Apache configuration. I’ll usually recommend this way, you can edit the site’s .htaccess file and use the following snippet:

          RewriteEngine On 
          RewriteCond %{HTTPS} !=on 
          RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
          

          Regards

          Hi I’m trying to setup a SSL cert and getting this error:

          SSL_CTX_use_PrivateKey_file(“/home///example.com.key”) failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)

          I am having the same issue were you able to solve this?

          This comment has been deleted

            Did you ever figure this out? I’m having the same issue

            Not sure where to begin to be honest. I am using a WordPress droplet with Apache and Ubuntu 14.04. I have a Comodo SSL certificate with a .crt file and .bundle file. I followed the instructions, making adjustments to the naming. I tried the instructions here regarding the default conf file and I tried the instructions from Comodo at https://support.comodo.com/index.php?/Default/Knowledgebase/Article/View/637/37/ for Apache & mod_ssl.

            I have keys and crt and bundle files in both /home/myusername/ and in the /etc/ssl/ directory

            My modified 000-default.conf features the following:

            Listen 443 http
            
            
            <VirtualHost *:80>
               ServerName www.digitera.com
               Redirect permanent / https://www.digitera.com/
            </VirtualHost>
            
            <VirtualHost *:443>
            ServerName www.digitera.com
            SSLEngine on
                    SSLCertificateFile /etc/ssl/digitera_com.crt
                    SSLCertificateKeyFile /etc/ssl/digitera.com.key
                    SSLCertificateChainFile /etc/ssl/digitera_com.ca-bundle
            
            ServerAdmin webmaster@localhost
                    DocumentRoot /var/www/html
            ErrorLog ${APACHE_LOG_DIR}/error.log
                    CustomLog ${APACHE_LOG_DIR}/access.log combined
            </VirtualHost>
            

            I added the Listen command after seeing it on a Ubuntu forum.

            I get the following error in Firefox when I try to connect via https://www.digitera.com

            An error occurred during a connection to www.digitera.com. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long) 
            

            In the comments section, Mitchell mentioned the default-ssl.conf file, but that is not part of the core tutorial.

            Which instructions should I be following ? The instructions from Comodo, the ones here ? Should I be modyifying just the 000-default.conf file or the default-ssl.conf one as well ? Should I be leaving the .bundle file name alone or should I rename it to match the convention that is indicated in the base tutorial ?

            Help !!!

            Ken

            Mitchell Anicas
            DigitalOcean Employee
            DigitalOcean Employee badge
            March 23, 2015

            Which version of Apache are you using? If it’s a 2.4.x, try replacing SSLCertificateChainFile with:

            SSLCACertificateFile /etc/ssl/digitera_com.ca-bundle
            

            Just a note about doing this if you have a one-click Drupal install:

            The file to edit won’t be

            sudo vi default
            

            But rather

            sudo vi drupal
            

            Then what you edit is not just one line but rather you need to edit this:

              listen 80 default_server;
              listen [::]:80 default_server ipv6only=on;
            

            into this:

              listen 443 ssl;
              listen [::]:443 ssl ipv6only=on;
            

            FInally you won’t find the ‘server_name’ line. So right below the above lines, insert it like so:

            server_name example.com;
            

            The rest works as described in the tutorial.

            alexdo
            Site Moderator
            Site Moderator badge
            October 30, 2024

            Thanks for sharing this! We’ll look into updating the article with the latest revision if necessary!

            Regards

            I was trying to generate a CSR and private key…

            Got to this point in the tutorial:

            "<^>This will generate a .key and .csr file. The .key file is your private key, and should be kept secure. The .csr file is what you will send to the CA to request your SSL certificate.

            You will need to copy and paste your CSR when submitting your certificate request to your CA. To print the contents of your CSR, use this command (replace the filename with your own):

            cat example.com.csr<^>"

            I was able to get the CSR, but where did the KEY go? Newbie here, any help appreciated. Thanks.

            Mitchell Anicas
            DigitalOcean Employee
            DigitalOcean Employee badge
            April 2, 2015

            The KEY should be in a file in the same directory as the CSR, with a name like example.com.key.

            Mitchell Anicas
            DigitalOcean Employee
            DigitalOcean Employee badge
            April 2, 2015

            This comment has been deleted

              Thank you for the quick reply. Couldn’t find it, I probably deleted/misplaced it somehow. So decided to generate a new CSR & Key and request a re-issue of a new SSL certificate instead. Got a new cert emailed from Comodo minutes later.

              Thanks for the tutorial. Any help is always apreciated.

              I will say though that I had to spend quite a while figuring out why I was getting the following browser errors.

              Google Chrome:

              SSL connection error
              
              Unable to make a secure connection to the server. This may be a problem with the server or it may be requiring a client authentication certificate that you don't have.
              

              Error code: ERR_SSL_PROTOCOL_ERROR

              Firefox:

              An error occurred during a connection to mymurdermystery.party. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)
              
              The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
              Please contact the web site owners to inform them of this problem.
              

              In the end I had to enable the configuration using:

              sudo a2ensite 000-default.conf

              alexdo
              Site Moderator
              Site Moderator badge
              October 30, 2024

              Thank you for sharing your solution, and I’m glad you figured it out! The ERR_SSL_PROTOCOL_ERROR and ssl_error_rx_record_too_long errors often indicate that Apache is listening for HTTPS traffic on a port where SSL isn’t configured correctly, or that the configuration itself isn’t fully enabled.

              Enabling your configuration with sudo a2ensite 000-default.conf was crucial because Apache requires the site configuration to be both enabled and active for SSL settings to take effect. Without that step, Apache can’t apply any SSL directives defined in the configuration file, which leads to SSL-related browser errors like the ones you experienced.

              Thanks again for the feedback! This will be helpful for anyone else troubleshooting similar issues!

              Regards

              Thanks Mitch

              Worked perfectly for me. I had absolutely no problems installing a wildcard SSL certificate from NameCheap on my Ubuntu 13.10 Apache 2.4.6 droplet.

              Hi there,

              I was trying to install SSL certificate on Apache 2.4.7 on Ubuntu 14.04 x64 following above instructions. I have purchased certificate from GoDaddy. After finishing all the steps of installation when I try to restart Apache server, I get error message saying ‘Apache start failed’ and my site becomes inaccessible. I have got the following message on my server error log file:

              [Tue Apr 14 07:31:14.140280 2015] [ssl:emerg] [pid 1192] AH02238: Unable to configure RSA server private key [Tue Apr 14 07:31:14.140478 2015] [ssl:emerg] [pid 1192] SSL Library Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch [Tue Apr 14 07:31:14.140496 2015] [ssl:emerg] [pid 1192] AH02311: Fatal error initialising mod_ssl, exiting. See /var/log/apache2/error.log for more information

              My server configuration file (000-default.conf) contains following lines:

              <VirtualHost *:80>
                 ServerName foodoli.com
                 Redirect permanent / https://mysite.com/
              </VirtualHost>
              
              <VirtualHost *:443>
                  ServerName foodoli.com
                  SSLEngine on
                  SSLCertificateFile /etc/ssl/mysite.com.crt
                  SSLCertificateKeyFile /etc/ssl/mysite.com.key
                  SSLCertificateChainFile /etc/ssl/intermediate.crt
              
                   ServerAdmin webmaster@localhost
                   DocumentRoot /var/www/html
              
                   <Directory /var/www/html/ >
                         Options Indexes FollowSymLinks MultiViews
                         AllowOverride All
                         Order allow,deny
                          allow from all
                    </Directory>
              </VirtualHost>
              
              

              I am kind of lost and can’t figure out where the actual problem is. Can you please help me here and let me know what the problem is? Thanks in advance.

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              April 14, 2015

              That means that your cert and key aren’t matching.

              To verify this, run the following commands:

              cd /etc/ssl
              openssl x509 -noout -modulus -in mysite.com.crt | openssl md5
              openssl rsa -noout -modulus -in mysite.com.key | openssl md5
              

              If the output doesn’t match exactly, you probably aren’t using the proper key file. You can either find the proper key file, or just create a new key and CSR and reissue the cert.

              Mitchell, this article was extremely helpful.

              However I have one question, in the section about “Install Certificate On Web Server,” you state that "the private key, SSL certificate, and, if applicable, the CA’s intermediate certificates are located in a home directory at /home/sammy"

              Is the “sammy” folder necessary for the process or is that an example name?

              Thank you for your clarification. This is my first time setting up an SSL.

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              April 16, 2015

              It’s an example username. The username that you should use is the one that you logged into the server as (and has sudo access).

              What if we don’t want to redirect all pages to https? If we are running a store and only want https on the checkout page would we set up the virtualhost *:80 and then copy everything from there into virtualhost *:443 to enable both without the redirect?

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              April 30, 2015

              There are a lot of different ways to do what you want.

              The problem with doing it the way you described is that your store will be accessible via HTTP. If you do it that way, you should at least redirect the directory of the store to the 443 VirtuaHost.

              I should probably give more detail. I’m using Wordpress/WooCommerce which has a checkbox to “force SSL on checkout” and “force http upon leaving checkout”. So the checkout page will be safe (assuming the SSL certificate gets installed correctly of course).

              What are the rammifications of having the shop pages accessible via http? Since it’s Wordpress I don’t think I can redirect certain directories although I could do a php redirect on all store pages I guess.

              Thanks for this great article and all the comments!

              I wanted to share some tips and trouble shooting techniques:

              1. Check that the SSL.crt and mydomain.key are owned by root. Make sure to protect your private key chmod 600 mydomain.key

              2. Contact Support

              3. Is the SSL certificate installed? openssl s_client -CApath /etc/ssl/ -showcerts -connect mydomain.com:443 -servername mydomain.com

              4. What webserver am I running? wget --save-headers mydomain.com

              5. What port is nginx listening on? netstat -tulpn | grep "nginx"

              6. Open up the 443 port: iptables -I INPUT -p tcp --dport 443 -j ACCEPT

              alexdo
              Site Moderator
              Site Moderator badge
              September 28, 2024

              Thanks for sharing this. Also if you’re using UFW you can use sudo ufw allow 443

              Regards

              So weird enough I got a comodo cert loaded it up on a default apache droplet ubuntu 14.04, getting the following when i hit the site with ssl enabled…

              Secure Connection Failed

              An error occurred during a connection to www.mycibt.com. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)

              The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
              Please contact the website owners to inform them of this problem.
              

              Here is my config file:

              <VirtualHost www.mysite.com:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

              <VirtualHost www.mysite.com:443> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLEngine on SSLCertificateFile /etc/apache2/ssl/certs/mysite.com.crt SSLCACertificateFile /etc/apache2/ssl/certs/intermediate.crt SSLCertificateKeyFile /etc/apache2/ssl/certs/mysite.com.key </VirtualHost>

              Any ideas on this?

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              May 13, 2015

              That error can be caused by a variety of things (usually misconfigured Apache). Check the Apache error log for more hints: sudo tail -f /var/log/apache2/error_log, then open the site in a browser.

              The tutorial is missing a command that needs to be sent before restarting the apache server: a2ensite default-ssl

              I have installed the Rapid ssl in my Ubuntu 14.04.2 LTS. But the website is not loading after that. I am getting following message in browser “The page isn’t redirecting properly”

              my apache version is apache 2.4.7

              The conf file is available in /etc/apache2/sites-available/magento.conf is as follows

              <VirtualHost *:80> ServerName mysite.co.uk Redirect permanent / https://mysite.co.uk/ </VirtualHost> <VirtualHost *:443> ServerName www.mysite.co.uk SSLEngine on SSLProtocol all SSLCertificateFile /etc/apache2/ssl/rapidssl_publickey_2015.crt SSLCertificateKeyFile /etc/apache2/ssl/private.key SSLCertificateChainFile /etc/apache2/ssl/rapidssl_intermediateca_2015.crt ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /var/www/html/magento> AllowOverride All Require all granted </Directory>

              </VirtualHost>

              vim: syntax=apache ts=4 sw=4 sts=4 sr noet

              The ports.conf available in /etc/apache2/ports.conf as follows

              Listen 80

              <IfModule ssl_module> Listen 443 </IfModule>

              <IfModule mod_gnutls.c> Listen 443 </IfModule>

              vim: syntax=apache ts=4 sw=4 sts=4 sr noet

              The apache error log I could see as follows: [Fri May 29 23:42:51.054552 2015] [ssl:warn] [pid 2048] AH01909: RSA certificate configured for www.funnfrolic.co.uk:443 does NOT include an ID which matches the server name [Fri May 29 23:42:51.054975 2015] [ssl:warn] [pid 2048] AH01909: RSA certificate configured for www.funnfrolic.co.uk:443 does NOT include an ID which matches the server name [Fri May 29 23:42:51.055076 2015] [ssl:warn] [pid 2048] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Fri May 29 23:42:51.222699 2015] [ssl:warn] [pid 2053] AH01909: RSA certificate configured for www.funnfrolic.co.uk:443 does NOT include an ID which matches the server name [Fri May 29 23:42:51.223298 2015] [ssl:warn] [pid 2053] AH01909: RSA certificate configured for www.funnfrolic.co.uk:443 does NOT include an ID which matches the server name [Fri May 29 23:42:51.223512 2015] [ssl:warn] [pid 2053] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) [Fri May 29 23:42:51.227454 2015] [mpm_prefork:notice] [pid 2053] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.6 OpenSSL/1.0.1f configured – resuming normal operations [Fri May 29 23:42:51.227484 2015] [core:notice] [pid 2053] AH00094: Command line: ‘/usr/sbin/apache2’

              Can you please guide me how we can resolve this? I have hosted the website in Digital Ocean. Also- everytime when I restart the apache- I could see following message and I am giving passphrase everytime. Is that something have any impact in the process?

              Apache needs to decrypt your SSL Keys for www.funnfrolic.co.uk:443 (RSA) Please enter passphrase:

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              June 1, 2015

              @rickthomas:

              1. “The page isn’t redirecting properly” is usually caused by a misconfigured application. Review your application’s settings that have to do with the URL or clear its cache.

              2. The ServerName directive in the :443 VirtualHost must match the CN (Common Name) that you set when you generated your key and CSR. This is probably causing the error in the Apache log.

              3. The passphrase prompt occurs because you encrypted your key with one when you created it. This can cause an issue if the process restarts automatically (e.g. after boot) and you aren’t there to enter the passphrase—Apache won’t start. You can create key without a passphrase by using the -nodes option. There are other ways around this, but this is the simplest. You will have to regenerate the key/CSR and get RapidSSL to issue a new certificate.

              Great Tutorial Thanks

              Help!

              I’m trying to get SSL to work on a client’s website (http://crsupplements.com/) and it doesn’t seem to be working. I am using DO’s one click Wordpress with Ubuntu 14.04 image, using Apache 2.4.7

              Here is my Apache Host configuration file. (/etc/apache2/sites-available/000-default.conf)

              <VirtualHost *:80>
                 ServerName crsupplements.com
                 Redirect permanent / https://crsupplements.com/
              </VirtualHost>
              <VirtualHost *:443>
               	ServerName crsupplements.com
              	SSLEngine on
              	SSLCertificateFile /home/elijah/CRSUPPLEMENTS.COM.crt
              	SSLCertificateKeyFile /home/elijah/crsupplements.com.key
              	SSLCertificateChainFile	/home/elijah/intermediate.crt
              
              	ServerAdmin admin@crsupplements.com
              	DocumentRoot /var/www/html
              
              	ErrorLog ${APACHE_LOG_DIR}/error.log
              	CustomLog ${APACHE_LOG_DIR}/access.log combined
              </VirtualHost>
              
              # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
              

              Going to https://crsupplements.com/ just says that the connection is untrusted and is a self-signed certificate. I can add an exception but it then says 403 Forbidden, you can’t access / on this server. I bought the domain and cert from register.com and they told me in what order to put the intermediate certs in, so I am pretty sure that is correct. What am I missing? Do I need to do something to WordPress? Thanks!

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              June 15, 2015

              Is 000-default.conf the only file that is linked in /etc/apache2/sites-enabled ?

              Did you get this fixed? I’m having the same problem now.

              my default-ssl.conf is the only linked file in /sites-enabled

              Is this where the problem is?

              Hello. I am having the same problem as well. How did you manage to fix your error? Thank you.

              A couple of good resources to test the certificate is all ‘clean & green’ :

              https://www.sslshopper.com/ssl-checker.html https://www.whynopadlock.com

              These will spot any problems with your SSL chain, and the last link will also identify non secure content.

              alexdo
              Site Moderator
              Site Moderator badge
              September 28, 2024

              I’ve used both sites in the past for test purposes and they work just fine. Another option will be to run a curl from the command line as well.

              Regards

              Hello, what application should I chose when I am using Nginx as a Reverse Proxy for Apache that I followed in this tutorials How To Configure Nginx as a Reverse Proxy for Apache.

              Thank you

              This was super, super helpful. Thank you!

              Awesome tutorial, Mitchell! But I have a problem. I am running a wordpress multisite, currently with 4 blogs. Two of them need SSL Certification. I successfully ran the tutorial to install the certificate for the main blog. Great. But than, all the blogs are pointing to the main url. Well, that was obvious, since the tutorial are redirecting *:80 to a single url. ( Important to say that I am using domain mapping, and before ssl config, the redirection was working properly. )

              I tried some configurations in the 000-default.conf, but none of them worked. Let me try some logic… yeah, I believe I’m wrong, but… Let’s say I have mainurl.ssl.com, that should have some subdomains, like store.mainurl.ssl.com. Also I have secondary.ssl.com, and thirdurl.nossl.com

              And here is the 000-default.conf I came up with:

              <VirtualHost *.mainurl.ssl.com:80>
                      ServerName mainurl.ssl.com
                      Redirect permanent / https://mainurl.ssl.com
              </VirtualHost>
              
              <VirtualHost secondaryurl.ssl.com:80>
                      #ServerName secondaryurl.ssl.com
                      Redirect 11.22.219.234 #my server ip
              </VirtualHost>
              
              <VirtualHost thirdurl.nossl.com:80>
                      ServerName thirdurl.nossl.com
                      Redirect 11.22.219.234
              </VirtualHost>
              
              
              <VirtualHost *.mainurl.ssl.com:443>
                      ServerName mainurl.ssl.com
                      SSLEngine on
                      SSLCertificateFile /home/paulo/mainurl.ssl.com.crt
                      SSLCertificateKeyFile /home/paulo/mainurl.ssl.com.key
                      SSLCACertificateFile /home/paulo/mainurl.ssl.com.ca-bundle
              
                      ServerAdmin webmaster@localhost
                      DocumentRoot /var/www/html
              
                      ErrorLog ${APACHE_LOG_DIR}/error.log
                      CustomLog ${APACHE_LOG_DIR}/access.log combined
              </VirtualHost>
              
              <VirtualHost secondaryurl.ssl.com:443>
                      ServerName secondaryurl.ssl.com
                      SSLEngine on
                      SSLCertificateFile /home/paulo/secondaryurl.ssl.com.crt
                      SSLCertificateKeyFile /home/paulo/secondaryurl.ssl.com.key
                      SSLCACertificateFile /home/paulo/secondaryurl.ssl.com.ca-bundle
              
                      ServerAdmin webmaster@localhost
                      DocumentRoot /var/www/html
              
                      ErrorLog ${APACHE_LOG_DIR}/error.log
                      CustomLog ${APACHE_LOG_DIR}/access.log combined
              </VirtualHost>
              
              <VirtualHost thirdurl.nossl.com:443>
                      #ServerName secondaryurl.ssl.com
                      
                      ServerAdmin webmaster@localhost
                      DocumentRoot /var/www/html
              
                      ErrorLog ${APACHE_LOG_DIR}/error.log
                      CustomLog ${APACHE_LOG_DIR}/access.log combined
              </VirtualHost>
              
              # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
              
              

              I use the ’ * ’ in <VirtualHost *.mainurl.ssl.com:80>, thinking in it’s the subdomains. I tried that, and other configurations, but none of them worked.

              Is there a way to setup SSL certificates for blogs in wordpress multisites? I would love some help on this.

              Thanks a lot!

              I Tried this tutorial too: https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-ssl-certificates-on-one-ip-with-apache-on-ubuntu-12-04

              But at the end, it result in error, apache said that de site did not exist. =P

              And I realized another problem, very serious one btw… Using permalink like url.com/category/my-post the browser did load the page at all, saying that was not possible to establish a segure connection. :(

              Mitchell,

              Excellent write up! TLS/SSL configuration instructions for Nginx was great, wanted to share config for Apache 2.4.x too for those of you who are concerned about SSLv3 and the poodle vulnerability.

              Edit: /etc/apache2/mods-available/ssl.conf

              SSLProtocol all
              

              –to something like–

              SSLProtocol TLSv1 TLSv1.1 TLSv1.2
              

              sudo service apache2 reload

              alexdo
              Site Moderator
              Site Moderator badge
              October 30, 2024

              Thanks for sharing this!

              As with the latest 1.3 version you can also add:

              SSLProtocol TLSv1.3
              

              Regards

              Hi Guys! I need a help:

              I have already a ssl certificate from godaddy installed in my domain >> mydomain.com.br Thats ok! working fine.

              But, now I need to setup another single cert in a subdomain (for my mobile version) >> m.mydomain.com.br

              How can I do this configuration in my droplet? I have a Ubuntu 12.10 x64 Server with Nginx

              The certificate is already in the right folder. I just need do setup the nginx configuration.

              Thanks!!!

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              July 23, 2015

              You can add a new server block in the /etc/nginx/sites-enabled directory.

              For example, open a new file called mobile:

              sudo vi /etc/nginx/sites-enabled/mobile
              

              Then add a new server block. It might look something like this:

              server {
                  listen 443 ssl;
                  server_name m.mydomain.com.br;
                  ssl_certificate /cert/path/m.mydomain.com.br.chained.crt;
                  ssl_certificate_key /cert/path/m.mydomain.com.br.key;
              ...
              }
              

              Then be sure to add the rest of your configuration in that server block.

              I followed the Apache instructions. Managed to break the site.

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              July 30, 2015

              Do you see anything in the error logs?

              I abandoned this approach and modified the desfault-ssl.conf file, which is really where this configuration should be done.

              I have followed these instructions and am no just timing out. If I point directly to the HTTPS version of the IP address it resolves, but obviously the cert shows an unmatching domain error.

              Any idea why the live site would be a white - timedout page?

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              July 31, 2015

              Which web server are you using? If the HTTP to HTTPS redirect isn’t working, try focusing on the port 80 VirtualHost or server block.

              I was able to fix the time out, but not have redirect loop errors. using the wordpress droplet, so apache. This is my 000-default.conf file: http://pastebin.com/PyxvBZDL

              I used a2dissite on all other confs, if that makes sense.

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              July 31, 2015

              Make sure you don’t have a stray redirect somewhere else, like an .htaccess file, and check your Wordpress permalink settings.

              After creating mydomain.ssl.conf do I need do keep mydomain.cont too, or may I delete it?

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              August 7, 2015

              I’m not sure what you mean. Could you clarify your question?

              sorry, I mixed your text with another I was reading about that. Let me clarify for you. Maybe you can help.

              My Nginx was installed with the default package from serverpilot.io. They install Nginx-sp, then my server block stays under this folder:

              /etc/nginx-sp/vhosts.d/mydomain/

              When I first went in this folder, there was a file called “mydomain.conf”. Then, I created another called “mydomain.ssl.conf” with all intructions you wrote in this article: listen 443 ssl; server_name example.com; ssl_certificate /home/sammy/example.com.chained.crt; ssl_certificate_key /home/sammy/example.com.key; AND ALL YOU MENTIONED…

              My question is if do I have to keep both files: original : /etc/nginx-sp/vhosts.d/mydomain/mydomain.conf and new : /etc/nginx-sp/vhosts.d/mydomain/mydomain.ssl.conf ???

              In the original file original : mydomain.conf there is the defaul configuration from Nginx-sp such as:

              server { listen 80; liste [::]80; server_name mydomain www.mydomain; root xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/public/; access_log xxxxxxxxxxx error_log xxxxxxxxx … }

              Thank you very much!

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              August 7, 2015

              It looks like your mydomain.conf file is configured to allow HTTP connections. If you want your users to be able to access your site through HTTP (in addition to HTTPS), you should keep the file. If you want HTTPS-only, you should probably redirect the HTTP traffic to HTTPS.

              I followed the tut exactly and I get secure connection failed when trying the URL via FF. I purchase a positive SSL from namecheap.com and this is my config file:

              <VirtualHost *:443>
              	# The ServerName directive sets the request scheme, hostname and port that
              	# the server uses to identify itself. This is used when creating
              	# redirection URLs. In the context of virtual hosts, the ServerName
              	# specifies what hostname must appear in the request's Host: header to
              	# match this virtual host. For the default virtual host (this file) this
              	# value is not decisive as it is used as a last resort host regardless.
              	# However, you must set it for any further virtual host explicitly.
              	ServerName gifthero.co.uk
              
              	# SSL setting
              	SSLEngine on
              	SSLCertificateFile /etc/apache2/ssl/gifthero_co_uk.crt
              	SSLCertificateKeyFile /etc/apache2/ssl/gifthero.co.uk.key
              	SSLCACertificateFile /etc/apache2/ssl/COMODORSAAddTrustCA.crt	
              
              	ServerAdmin i@gifthero.co.uk
              	DocumentRoot /var/www/html
              
              	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
              	# error, crit, alert, emerg.
              	# It is also possible to configure the loglevel for particular
              	# modules, e.g.
              	#LogLevel info ssl:warn
              
              	ErrorLog ${APACHE_LOG_DIR}/error.log
              	CustomLog ${APACHE_LOG_DIR}/access.log combined
              
              	# For most configuration files from conf-available/, which are
              	# enabled or disabled at a global level, it is possible to
              	# include a line for only one particular virtual host. For example the
              	# following line enables the CGI configuration for this host only
              	# after it has been globally disabled with "a2disconf".
              	#Include conf-available/serve-cgi-bin.conf
              </VirtualHost>
              # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
              
              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              August 13, 2015

              Is there a more specific error code after the “Secure Connection Failed” line? That will usually help you pinpoint the issue. If not, you can check the Apache error log (sudo tail /var/log/apache2/error.log). Please post the error code.

              If I have more than 1 CA certificates how would I need to name them? I have 3

              Mitchell Anicas
              DigitalOcean Employee
              DigitalOcean Employee badge
              August 13, 2015

              The names are arbitrary. If you have three intermediate certificates from different providers, you should probably name them based on the CAs that they belong to.

              If you have three different sites with separate SSL certificates, you will probably want to name them after the domains that they cover.

              After configuring apache for my SSL certificate (all certificates created and uploaded successfully) I’m still finding that https web requests are completely ignoring the certificates or are unable to find it. What do I need to do with my .conf files or my virtual hosts in order to use the settings in “/000-default.conf” ???

              I’ve already disabled the default “self-signed” ssl by changing the virtualhost in “default-ssl.conf” to:

              <VirtualHost 127.0.0.1:443>

              (before ssl labs site test was showing the default self-signed ssl)

              It looks like this has to do with the default settings that the wordpress ubuntu package comes with, so any help or direction would be great, thanks so much.

              Graham

              alexdo
              Site Moderator
              Site Moderator badge
              October 30, 2024

              To ensure Apache is using your new SSL certificate and not falling back to the self-signed one, here are some adjustments you can make:

              1. Specify the SSL Certificate in Virtual Host: Open your SSL virtual host file (e.g., /etc/apache2/sites-available/000-default.conf or create a new SSL virtual host file if needed), and add the SSLEngine, SSLCertificateFile, and SSLCertificateKeyFile directives to specify your certificate paths:
              <VirtualHost *:443>
                  ServerName yourdomain.com
                  DocumentRoot /path/to/your/site
              
                  SSLEngine on
                  SSLCertificateFile /path/to/your/certificate.crt
                  SSLCertificateKeyFile /path/to/your/private.key
                  SSLCertificateChainFile /path/to/your/chainfile.pem  # Optional, if needed
              
                  # Additional configuration (e.g., for WordPress)
                  <Directory /path/to/your/site>
                      AllowOverride All
                  </Directory>
              </VirtualHost>
              
              1. Disable the Default SSL Configuration: Since you modified default-ssl.conf, ensure it’s disabled to avoid conflicts:
              sudo a2dissite default-ssl
              
              1. Enable Your Custom SSL Configuration: If 000-default.conf is your custom SSL virtual host file, enable it to make sure Apache reads it:
              sudo a2ensite 000-default.conf
              
              1. Verify Modules and Reload: Make sure the ssl and rewrite modules are enabled, then restart Apache:
              sudo a2enmod ssl rewrite 
              sudo systemctl restart apache2
              
              1. Check Apache’s Default SSL Host: Apache may need a specific default SSL host for HTTPS requests. If you want 000-default.conf to be the default, ensure no other configurations are intercepting HTTPS traffic.

              After these changes, try running an SSL test again. Let me know if this resolves it or if more details are needed on the WordPress package configuration!

              Regards

              Don’t forget you may have previously used iptables to lock down your server. After setting up the SSL and then getting a timeout with no errors in the logs;

              In Ubuntu sudo ufw allow 443

              alexdo
              Site Moderator
              Site Moderator badge
              September 28, 2024

              This is a valid point. You should make sure that port 443 is open and allowed in your Firewall configuration.

              Regards

              This comment has been deleted

                This is an excellent guide!! Thank you for explaining not just the technical details, but also some of the background regarding different SSL products and certificate types. This has really been enlightening.

                Try DigitalOcean for free

                Click below to sign up and get $200 of credit to try our products over 60 days!

                Sign up

                Join the Tech Talk
                Success! Thank you! Please check your email for further details.

                Please complete your information!

                Become a contributor for community

                Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

                DigitalOcean Documentation

                Full documentation for every DigitalOcean product.

                Resources for startups and SMBs

                The Wave has everything you need to know about building a business, from raising funding to marketing your product.

                Get our newsletter

                Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

                New accounts only. By submitting your email you agree to our Privacy Policy

                The developer cloud

                Scale up as you grow — whether you're running one virtual machine or ten thousand.

                Get started for free

                Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

                *This promotional offer applies to new accounts only.