julienr
By:
julienr

Cannot install an SSL

January 17, 2017 454 views
Apache

Hi all,

I followed this guide to install a Comodo SSL to my VPS : https://www.digitalocean.com/community/tutorials/how-to-install-an-ssl-certificate-from-a-commercial-certificate-authority (Apache version)

First, I used Filezilla to upload the files I received from Comodo to /etc/ssl

Than I followed the instructions to modify 000-default.conf

This is the result:


<VirtualHost *443>
        ServerName www.mydomain.com
        Redirect permanent / https://www.mydomain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        SSLEngine on
        SSLCertificateFile /etc/ssl/mydomain.crt
        SSLCertificateKeyFile /etc/ssl/mydomain.key
        SSLCACertificateFile /etc/ssl/mydomain.ca-bundle

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Would the problem be caused by the .ca-bundle?

Thanks!

2 Answers
jtittle1 January 17, 2017
Accepted Answer

@julienr

As per the guide you've linked to, you should have two VirtualHost blocks -- one serving requests on Port 80 and then one similar to the above that handles requests on Port 443 (i.e. SSL).

Your first VirtualHost block should look like the one shown below (of course, using your domain).

<VirtualHost *:80>
    ServerName mydomain.com
    Redirect permanent / https://mydomain.com
</VirtualHost>

Directly below the above, we set the VirtualHost block that handles the actual SSL connections.

<VirtualHost *:443>
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    SSLEngine on
    SSLCertificateFile /etc/ssl/mydomain.crt
    SSLCertificateKeyFile /etc/ssl/mydomain.key
    SSLCACertificateFile /etc/ssl/mydomain.ca-bundle

    <Directory /var/www/html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The difference between the above SSL definition and the one you provided in your original post is that the first line where you open the VirtualHost block, you need a colon between the asterisk and the port. The second issue which has been removed from the original is the line that redirects. You want to redirect from port 80 to port 443, not redirect port 443 to 443 :-).

You'll want to replace mydomain.com with your actual domain, make sure the paths above are real paths, and then restart apache. That should help to get you up and running.

If you run in to any errors, you'll want to take a look at the error log and see what's showing as the error log often provides more details than what you'll see in-browser.

Thanks, it worked!

Have another answer? Share your knowledge.