Note: You may want to consider using Let’s Encrypt instead of the StartSSL.com process below. Let’s Encrypt is a new certificate authority that provides a free and easy way of creating SSL/TLS certificates that are trusted in most web browsers. Check out the tutorial to get started: How To Secure Apache with Let’s Encrypt on Ubuntu 14.04
Before we get started, here are the web tools you need for this tutorial:
<ol>
<li><a href="https://www.google.com/intl/en/chrome/browser">Google Chrome</a> browser</li>
<li>Apache installed on your VPS (cloud server)</li>
<li>A domain name you own</li>
<li>Access to an email address at that domain, either:
<ol>
<li>postmaster@duable.co</li>
<li>hostmaster@duable.co</li>
<li>webmaster@duable.co</li>
</ol>
</li>
</ol>
StartSSL.com offers completely free verified (your users won't have to see those scary red screens saying "this site isn't trusted" anymore) SSL certificates that you can use on your website. This is a great deal as most companies charge $50-$60 for similar services. The free version is a bit tricky to set up, but it's well worth it.
To get started, browse to StartSSL.com and using the toolbar on the left, navigate to StartSSL Products and then to StartSSL™ Free. Choose the link for Control Panel from the top of the page.
Make sure you are using Google Chrome
<ol>
<li>Choose the <strong>Express Signup.</strong> option</li>
<li>Enter your personal information, and click continue.</li>
<li>You'll get an email with a verification code inside it shortly. Copy and paste that email into the form on StartSSL's page.</li>
<li>They will review your request for a certificate and then send you an email with the new info. This process might take as long as 6 hours though, so be patient.</li>
<li>Once the email comes, use the link provided and the new authentication code (at the bottom of the email) to continue to the next step.</li>
<li>They will ask you to Generate a private key and you will be provided with the choice of "High" or "Medium" grade. Go ahead and choose "High".</li>
<li>Once your key is ready, click Install.</li>
<li>Chrome will show a popdown that says that the certificate has been succesfully installed to Chrome.</li>
</ol>
<p>This means your browser is now authenticated with your new certificate
and you can log into the StartSSL authentication areas using your new
certificate. Now, we need to get a properly formatted certificate set up for
use on your VPS. Click on the <a
href="https://www.startssl.com/?app=12">Control panel</a> link again, and
choose the Authenticate option. Chrome will show a popup asking if you want
to authenticate and will show the certificate you just installed. Go ahead
and authenticate with that certificate to enter the control panel.</p>
<p>You will need to validate your domain name to prove that you own the
domain you are setting up a certificate for. Click over to the Validations
Wizard in the <a href="https://www.startssl.com/?app=12">Control panel</a>
and set Type to Domain Name Validation. You'll be prompted to choose
from an email at your domain, something like postmaster@yourdomain.com.</p>
Check the email inbox for the email address you selected. You will get yet another verification email at that address, so like before, copy and paste the verification code into the StartSSL website.
Next, go to the Certificates Wizard tab and choose to create a Web Server SSL/TLS Certificate.
Hit continue and then enter in a secure password, leaving the other settings as is.
You will be shown a textbox that contains your private key. Copy and paste the contents into a text editor and save the data into a file called ssl.key.
When you click continue, you will be asked which domain you want to create the certificate for:
Choose your domain and proceed to the next step.
You will be asked what subdomain you want to create a certificate for. In most cases, you want to choose www here, but if you'd like to use a different subdomain with SSL, then enter that here instead:
StartSSL will provide you with your new certificate in a text box, much as it did for the private key:
Again, copy and paste into a text editor, this time saving it as ssl.crt.
You will also need the StartCom Root CA and StartSSL's Class 1 Intermediate Server CA in order to authenticate your website though, so for the final step, go over to the Toolbox pane and choose StartCom CA Certificates:
At this screen, right click and Save As two files:
<ul>
<li>StartCom Root CA (PEM Encoded) (save to ca.pem)</li>
<li>Class 1 Intermediate Server CA (save to sub.class1.server.ca.pem)</li>
</ul>
For security reasons, StartSSL encrypts your private key (the ssl.key file), but your web server needs the unencrypted version of it to handle your site's encryption. To unencrypt it, copy it onto your server, and use the following command to decrypt it into the file private.key:
openssl rsa -in ssl.key -out private.key
OpenSSL will ask you for your password, so enter it in the password you typed in on StartSSL's website.
At this point you should have five files. If you're missing any, double-check the previous steps and re-download them:
<ul>
<li>ca.pem - StartSSL's Root certificate</li>
<li>private.key - The unencrypted version of your private key (be very careful no one else has access to this file!)</li>
<li>sub.class1.server.ca.pem - The intermediate certificate for StartSSL</li>
<li>ssl.key - The encrypted version of your private key (does not need to be copied to server)</li>
<li>ssl.crt - Your new certificate</li>
</ul>
You can discard the ssl.key file. If you haven't already copied the others onto your server you upload them there now:
scp {ca.pem,private.key,sub.class1.server.ca.pem,ssl.crt} YOURSERVER:~
<h2>Activating the certificate in Apache</h2>
Having a certificate isn't any good if you can't actually use it. This section explains how to configure Apache to use your new SSL certificate. These instructions are for Apache running on recent versions of Ubuntu VPS. For other Linux-based distros or web servers, you'll have to adjust accordingly.
First, create the folders where we'll store the keys. Enable Apache's SSL module, and restart Apache.
sudo a2enmod ssl sudo service apache2 restart sudo mkdir -p /etc/apache2/ssl
Copy the files you set up in the previous section into the /etc/apache2/ssl folder on your VPS.
sudo mkdir -p /etc/apache2/ssl cp ~/{ca.pem,private.key,sub.class1.server.ca.pem,ssl.crt} /etc/apache2/ssl
Execute:
ls /etc/apache2/ssl
And it should return:
ca.pem ssl.crt private.key sub.class1.server.ca.pem
Now, open your apache2 configuration file. Unless you've already modified the default configuration, input:
nano /etc/apache2/sites-enabled/000-default
It should look something like this:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
Copy the entire script above (from <VirtualHost *:80> to </VirtualHost>), paste it below the existing one, and change the top line from:
<VirtualHost *:80>
to
<VirtualHost *:443>
And add the following lines after the <VirtualHost *:443> line:
SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM SSLCertificateFile /etc/apache2/ssl/ssl.crt SSLCertificateKeyFile /etc/apache2/ssl/private.key SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem
The end result should look like this:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> <VirtualHost *:443> SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM SSLCertificateFile /etc/apache2/ssl/ssl.crt SSLCertificateKeyFile /etc/apache2/ssl/private.key SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
Save your files and restart Apache with:
sudo service apache2 restart
You can check Apache's log files to see if there are any show stopping errors with this command:
cat /var/log/apache2/error.log
If everything looks good, try accessing your site in your web browser using an HTTPS URL (e.g. https://www.YOURSITE.com). When your site loads, you should see a little green padlock icon next to the URL. Click on it and you should see the following. The connections tab should show that the site's identity has been verified by StartCom.
Congratulations! You are all set!
<p>Reference Links:</p>
Here are some of the other posts I consulted when putting this together. If you run into any problems they might be a source of inspiration on how to fix them:
<ul>
<li><a href="http://www.debian-administration.org/articles/349">Apache SSL Configuration</a></li>
<li><a href="http://jasoncodes.com/posts/startssl-free-ssl">StartSSL Apache Guides</a></li>
</ul>
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
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!
I have tried to use startssl 3 times does not work but it does weirdly. I guess they hate me
If you are still facing an issue with StartSSL, you should definitely try other providers. (you can easily find good deal from authorized re-sellers)
Have you combine with root CA ?. The certificate without combine with root CA may cause of problem on old android device.
Try it, it working for.
Setup SSL
@mlwalk3r: Have you tried contacting them? They usually respond very quickly.
Some of these articles need to be written for utter newbies, for example - when it says upload to server, where should abouts should I upload it to?
Agreed! I’m struggling to do just this & the postfix thing. It may be easy for some but for me, it’s not a walk in the park ;(
@212nath: The command you need to run to upload the files to the droplet is right below that paragraph:
<img src=“http://i.imgur.com/GwiGmeq.png” alt=“Screenshot” />
Nope, that command that doesn’t instruct the higher-to-be to pick up those files where I leave them on my desktop.
But I’m gonna try cahuk solution below.
For SSH copy with scp you can use:
scp ca.pem private.key sub.class1.server.ca.pem ssl.crt username@ip_of_your_server:/home/username/
Otherwise, great howto.
And it is better to edit /etc/apache2/sites-enabled/default-ssl because editing 000-default broke my access to domain.com/iredadmin and awstats.
Nice howto,
But is here a tutorial on how to enable ssl on only one-two pages? I only want ssl on my register page and login page. Eg. mysite.com/register mysite.com/login. I bought two SSL certs, one for my desktop site and one for my mobile version. mysite.com m.mysite.com
@KiwoT: You can’t protect only two pages easily. Why do you want to do that? The cookies will be passed in clear-text (thus the session keys) which would render SSL useless.
Wont SSL slow down the website and add overhead to the server resources? Thats why I only wanted to use my SSL on my login page and registration page. Seen alot of other websites doing this, but is it a bad idea? thanks.
@KiwoT: The performance overhead isn’t that great so I recommend enabling it on all pages.
This didn’t work right out of the box for me - I wasn’t able to restart apache after I altered ‘sites-enabled/000-default’
Apache needs the server name to be specified!
Adding the line
ServerName [your-domain.com]
to the TOP of the file did the trick for me.
So thankful for this tutorial! Thank you :)
@212nath The file should be uploaded into your root folder, then that openssl command should work just fine — just remember that you’ll be moving these files to your newly created ssl folder under apache2 in later steps…
hope that helps anyone else who was confused.
Well, I ran cat /var/log/apache2/error.log and oohh booooy, tons of errors. But I took a look and most error are like “File does not exist: /var/www/73-plasma” and I think it’s because I’m still fighting htaccess configuration Would anyone bother to look my log here and tell me if anything is ok? Link to the file (BR link Shortener) http://migre.me/gtZ6d
@jntslvdrt: Please pastebin your virtualhost files and the output of <code>ls -l /var/www</code>
http://pastebin.com/Z0xFs5gv Thanks :D
Apache is trying to access <strong>/var/www/73-plasma</strong> which doesn’t exist. There’s your problem. :]
Oohh, I see. Thanks for your support. I’m using OpenCart and then I set it to use friendly URLs and I’m studying how .htaccess works. That’s why 73-plasma does not exists.
awesome article! worked smoothly and verification from startssl only took about 10 minutes.
as someone has said, it’s better to edit /etc/apache2/sites-enabled/default-ssl but otherwise everything else in this is great!
Thanks for the tutorial! What I don’t get is why the Apache certificate setup is not in a domain specific config file? The certificate only works for one domain, right? And there are usually many domains/vhosts set up on one server? On that point, is it possible using this technique to set up multiple SSL certificates on the same server?
You can use a multi domain ssl certificate.
Have a look at this guide - it explains how to setup Apache with multiple SSL vhosts (using one IP address and working with old browsers):
Setup Multiple SSL Domain Names on one IP Address
I start by installing Magento from the one click install. After the install I came straight to this tutorial.
At the step that says to open the config file nano /etc/apache2/sites-enabled/000-default
There is no 000-default file in that folder. Only magento-ssl.conf and magento.conf. Neither of them look like they have the right content inside to be the right file.
I’m supposed to add the following at this stage but not sure where to add it. SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /etc/apache2/ssl/ssl.crt
SSLCertificateKeyFile /etc/apache2/ssl/private.key
SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem
There is a 000-default.config file under sites-available but I don’t think that right either.
Can any one provide some advice here?
Thanks
I have same issue, found 000-deafult.conf file in the /etc/apache2/sites-available/ path but not sure if I should mess with this one as its not the path specified by the author.
Author wrote it incorrectly, it should’ve been nano /etc/apache2/sites-enabled/000-default.conf
@jo: Simply create another virtualhost (with a different SSL cert preferably) for the second domain and it should work. Also add <code>ServerName domainname.com</code> to each Virtualhost (right under ServerAdmin or <Virtualhost>).
i follow instruction create ssl from start ssl here and install it to centos 6 (https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-apache-for-centos-6), but it said server certificate does not match the url and server certificate not trusted. what is the mean? should i put domain name that i register to startssl or www.domain.com like above instruction? why server certificate not trusted?
You must use your own domain name instead of domain.com.
@kamal, domain.com just example, actualy it is https://dagosearch.com. but the result said server certificate does not match the url and server certificate not trusted. what is the mean?
@oscar.perdanakusuma: I can’t access dagosearch.com. Is your droplet up?
it seems after i make 443 vhost, apache restart,and it did not start (failed). i found this on error_log: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) RSA server certificate is a CA certificate (BasicConstraints: CA == TRUE !?) Unable to configure RSA server private key SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
what is the mean sir kamal?
@oscar.perdanakusuma: It means that the certificate you configured apache to use is invalid. It’s trying to use StartSSL’s CA certificate and not your website’s certificate.
@mr. kamal i just follow the guide as descripe above to get ssl certificate (ssl.crt). and configure in directory as descripe above: SSLCertificateFile /etc/httpd/ssl/ssl.crt
SSLCertificateKeyFile /etc/httpd/ssl/private.key
SSLCertificateChainFile /etc/httpd/ssl/sub.class1.server.ca.pem
to get private.key, i use this command: openssl rsa -in /etc/httpd/ssl/ssl.key -out /etc/httpd/ssl/private.key
which steps did i miss or wrong, sir kamal? or the steps to get certificate as descripe above are wrong?
on this line: You will be asked what subdomain you want to create a certificate for. In most cases, you want to choose www here, but if you’d like to use a different subdomain with SSL, then enter that here instead. StartSSL will provide you with your new certificate in a text box. Again, copy and paste into a text editor, this time saving it as ssl.crt.
is this the correct certificate? so, i register www.dagosearch.com as ssl.crt,
I use this setting in my apache config to allow virtual hosts by name: NameVirtualHost *
In conjunction with named hosts like: <VirtualHost *:80> ServerName domain.com … <VirtualHost *:80> ServerName sub.domain.com … <VirtualHost *:443> ServerName domain.com
But it was causing this error: [error] VirtualHost :80 – mixing * ports and non- ports with a NameVirtualHost address is not supported, proceeding with undefined results
So I figured out that I can still allow non-ssl subdomains while having ssl on domain.com if I just changed the directive to this instead: NameVirtualHost *:80
Hope that helps anyone else in a similar situation
@oscar.perdanakusuma: That is correct. How did you copy ssl.crt?
sir kamal, when it shown, i copy it with ctrl+a, start from begin certificate to end. and save it into notepad as ssl.crt. did it wrong,sir kamal?
This SSL only installed in Chrome? if my visitor using FireFox, IE then it will not work?
They key you install is for verification on their site. The SSL key you download will work on all browsers when you’ve installed it on the server.
Worked great :)
will this work with nginx as well?
@rb: It should work with nginx however the configuration won’t be the same, check out <a href=“http://www.westphahl.net/blog/2012/01/03/setting-up-https-with-nginx-and-startssl/”>http://www.westphahl.net/blog/2012/01/03/setting-up-https-with-nginx-and-startssl/</a>.
Is there any different setup if using it on a subdomain? example clients.domain.com?
Thank you mate. Saved me time and steps clearly explained. Cheers.
Great tutorial. The only issue I found was:
sudo mkdir -p /etc/apache2/ssl cp ~/{ca.pem,private.key,sub.class1.server.ca.pem,ssl.crt} /etc/apache/ssl
Needs to be updated. The “apache” in “/etc/apache/ssl” should be “apache2” ie. “/etc/apache2/ssl”
This is with a free signed SSL. If you’re using a commercial one like Comodo or RapidSSL, you’ll experience problems.
Here’s a guide that will make your life much easier: http://fang.ws/blog/how-to-install-ssl-certificate-apache-ubuntu
Thanks for the great tutorial. I guess the line:
cp ~/{ca.pem,private.key,sub.class1.server.ca.pem,ssl.crt} /etc/apache/ssl should read cp ~/{ca.pem,private.key,sub.class1.server.ca.pem,ssl.crt} /etc/apache2/ssl
@MarleyJaffe, @majed: Thanks for catching that! Updated.
Digital Ocean: Please provide a shared SSL already! :\
is this applicable for debian or centos?
@admin This is targeted at Debian and Ubuntu, but the steps are largely the same on CentOS. Though somethings are named differently. We have an article explaining how to set up a self signed SSL cert on CentOS:
https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-apache-for-centos-6
You could follow that, but skip step three where you generate a cert and just use the one provided to you from your certificate authority.
Great my email server is up and logging in on https://
one thing in apache log though:
[Thu Apr 24 05:26:44 xxxx] [warn] RSA server certificate CommonName (CN) `www.mydomain.us’ does NOT match server name!?
[Thu Apr 24 05:26:44 xxxx] [warn] mod_wsgi: Compiled for Python/2.7.2+. [Thu Apr 24 05:26:44 xxxx] [warn] mod_wsgi: Runtime using Python/2.7.3. [Thu Apr 24 05:26:44 xxxx] [notice] Apache/2.2.22 (Ubuntu) mod_ssl/2.2.22 OpenSSL/1.0.1 mod_wsgi/3.3 Python/2.7.3 configured – resuming normal operations
[Thu Apr 24 05:28:42 xxxx] [error] [client 24.177.199.xx] File does not exist: /var/www/favicon.ico
I guess I need a Cmame reccord for www.mydomain.us? Using wrong version File does not exist: /var/www/favicon.ico no idea will google it.
@stevehendo34: You need to make sure that the subdomain that you entered when generating the key on StartSSL matches the subdomain that you are actually using.
It’d be really helpful to have an article to help us active that on nginx! I’m running a nginx server here on DO, so I’ll wait for an official article to come up.
Thanks anyway.
Why do I have enter a passphrase every time I reboot server? Also I have installed iRedMail, how would I go about modifying/adding files in order to serve https? I am running Ubuntu 12.04. This is the list of files under /etc/apache2 : apache2.conf apache2.conf.2014.05.18.13.29.28 drwxr-xr-x 2 root root 4096 May 18 19:35 conf.d -rw-r–r-- 1 root root 1322 Feb 6 2012 envvars -rw-r–r-- 1 root root 177 May 18 15:06 httpd.conf -rw-r–r-- 1 root root 31063 Feb 6 2012 magic drwxr-xr-x 2 root root 4096 May 18 13:35 mods-available drwxr-xr-x 2 root root 4096 May 18 13:36 mods-enabled -rw-r–r-- 1 root root 750 May 21 10:04 ports.conf drwxr-xr-x 2 root root 4096 May 21 11:14 sites-available drwxr-xr-x 2 root root 4096 May 21 09:39 sites-enabled
List of files under sites-available: -rw-r–r-- 1 root root 8153 May 21 11:14 default-ssl -rw-r–r-- 1 root root 303 May 21 11:12 ormondkwikstop.com.conf -rw-r–r-- 1 root root 950 May 21 10:45 default -rw-r–r-- 1 root root 7469 May 18 13:36 default-ssl.2014.05.18.13.29.28
The default.conf file look like this: <VirtualHost *:80> ServerAdmin webmaster@localhost
</VirtualHost>
Finally my site files look like this:
<VirtualHost *:80> ServerAdmin postmaster@ormondkwikstop.com ServerName ormondkwikstop.com ServerAlias www.ormondkwikstop.com DocumentRoot /var/www/ormondkwikstop.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
index.html look like:
<html> <head> <title>Welcome to Kwik Stop Discount Beverage - Ormond Beach</title> </head> <body> <h1>Success! The ormondKwikStop.com virtual host is working!</h1> </body> </html>
I am very novice. Where would I insert this code (<virtualHost*.443> …</VirtualHost>) from guide above?:
<VirtualHost *:443> SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
What’s in “/etc/apache2/sites-enabled/” just “ormondkwikstop.com.conf” ? If that’s the site you want available over https, then you’d add this to that file:
<pre> <VirtualHost *:443> SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
</VirtualHost> </pre>
@asb I have installed the rapid ssl and followed all steps you guys mentioned here. But- none of them worked for me. I have files called magento.conf magento-ssl.conf in /etc/apache2/sites-available and the magento.conf files are as follows
The ports.conf under /etc/apache2 is
Can you please help to sort the https://www.funnfrolic.co.uk
@rickthomas: Your website is loading fine for me. Are you still experiencing any issues? If so, try clearing your browser’s cache.
@AndrewSB: When I add the above code as is, and when I start apache2 service I get the following error:
In /etc/apache2/sites-available there are other file as I listed in my previous post and here it is again:
root@mailserver:/etc/apache2/sites-available# ls -lt total 24 -rw-r–r-- 1 root root 8153 May 21 11:14 default-ssl -rw-r–r-- 1 root root 303 May 21 11:12 ormondkwikstop.com.conf -rw-r–r-- 1 root root 950 May 21 10:45 default -rw-r–r-- 1 root root 7469 May 18 13:36 default-ssl.2014.05.18.13.29.28
Also why do I have to add passphrase every time restart?
Thanks for your response.
@r2d2t2: It sounds like you’ve defined a VirtualHost listening on port 443 already. What files are in “/etc/apache2/sites-enabled/” This is different than sites-available. sites-enabled shows the actually active configurations while sites-available show available configurations. When you “enable” a configuration file, it makes a link between the file in sites-enabled and sites-available.
@AndrewSB: First of all I am sorry that rushed my previous post. You asked for the files in sites-enables directory and I posted files in sites-available. Please forgive me for the haste.
Here is the list of files in sites-enabled directory:
root@mailserver:/etc/apache2/sites-enabled# ls -lt total 0 lrwxrwxrwx 1 root root 42 May 20 17:29 ormondkwikstop.com.conf -> …/sites-available/ormondkwikstop.com.conf lrwxrwxrwx 1 root root 30 May 18 13:36 default-ssl -> …/sites-available/default-ssl lrwxrwxrwx 1 root root 26 May 18 13:34 000-default -> …/sites-available/default
Here is the code in default-ssl that has defined a VirtualHost listening on port 443 already as you mentioned. This port 443 was defined by iRedMail installation in my opinion. How would I change this default-ssl so that https traffic get routed properly?
<IfModule mod_ssl.c> <VirtualHost default:443> ServerAdmin webmaster@localhost
<FilesMatch “.(cgi|shtml|phtml|php)$”> SSLOptions +StdEnvVars </FilesMatch> <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> BrowserMatch “MSIE [2-6]”
nokeepalive ssl-unclean-shutdown
downgrade-1.0 force-response-1.0 # MSIE 7 and newer should be able to use keepalive BrowserMatch “MSIE [17-9]” ssl-unclean-shutdown
Alias /cluebringer “/usr/share/postfix-cluebringer-webui/webui/” Alias /iredadmin/static “/usr/share/apache2/iredadmin/static/” WSGIScriptAlias /iredadmin “/usr/share/apache2/iredadmin/iredadmin.py/” Alias /awstats/icon “/usr/share/awstats/icon/” Alias /awstatsicon “/usr/share/awstats/icon/” ScriptAlias /awstats “/usr/lib/cgi-bin/” Alias /mail “/usr/share/apache2/roundcubemail/” Alias /phpmyadmin “/usr/share/phpmyadmin/” </VirtualHost> </IfModule>
@r2d2t2: SSL seems to be working for your site if I go to https://ormondkwikstop.com/
Is your only issue now that it asks you for a password?
@Andrew: Well I pasted the code below in default-ssl but now iredadmin does not work. So I am not sure how to combine both into default-ssl file so that iredamdin as well https for my site would work?
pasphrase is still the problem for me.
<VirtualHost *:443> SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
</VirtualHost>
I am indeed very grateful to you for your help.
In default-ssl, you can change DocumentRoot to “/var/www/ormondkwikstop.com/public_html” and add:
<pre> ServerName ormondkwikstop.com ServerAlias www.ormondkwikstop.com </pre>
Then replace the self-signed certs that iredadmin generated with:
<pre> SSLCertificateFile /etc/apache2/ssl/ssl.crt SSLCertificateKeyFile /etc/apache2/ssl/private.key SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem </pre>
As for the password, see: https://www.startssl.com/?app=25#34
@Andrew: Thanks for your help and everything is working file.
Before I go ahead and start configuring Apache I just have a quick question.
I’m using the SSL Cert for an email server, running POP3. I don’t plan on using the server for HTTP. When prompted by StartCom for the subdomain, I entered ‘pop3’ as this is what I use for email clients, i.e pop3.domain.tld
How do I configure Apache to work with this? I can see that you set up a virtual user underneath /var with /www but this is almost like it expects HTTP traffic, not POP3?
That said, I did notice that the certificate also covers the whole domain.tld, not just sub.domain.tld
Thanks
@Andrew Tanner: If you don’t want an HTTP server, you don’t need to install Apache at all.
Hi,
I am setting this up for a droplet with Virtualmin. I need the certificate to enable SSL in the main site:
domain.com
and in a sub-server which hosts the webmail application:
webmail.domain.com
My question is: do I need to setup one or two certificates for this??
Many thanks
@Andy "This is with a free signed SSL. If you’re using a commercial one like Comodo or RapidSSL, you’ll experience problems. Here’s a guide that will make your life much easier: http://fang.ws/blog/how-to-install-ssl-certificate-apache-ubuntu "
…may thanks! Just spent over an hour trying to find a clear, concise guide that does what you’ve written; too many of the Google search results seem to assume that because I’m using openssl, I want to use a free or a self-signed certificate.
Cheers!
Dez.
Perfect ! :)
I love those kind of detailled topics ;)
Thanks!!
AWESOME tutorial. Best I’ve seen on the internet! Thanks!
The only thing I did different was to change my VirtualHost *:80 to the below lines so that it would force HTTPS.
Excellent Tutorial … Thanks a lot for this one… I successfully setup SSL for my site …
Thanks - worked perfectly!
I followed every step and generated a key for the www. subdomain but on restarting apache I see this in logs:
I have not been able to troubleshoot this. It does not work when I try access the domain as https://domain.com
What do you think might be the problem?
@kantwk: That’s fine, it’s a notice that someone has reloaded apache2. Check if apache2 is listening on port 443:
If it is, what’s the output of the following command?
Running
netstat -plutn | grep 443
shows apache2 is using the port andGives
Status: inactive
.I hope the information above helps.
@kantwk: Is apache2 listening on 0.0.0.0:443 or 127.0.0.1:443? Can you pastebin the output of
sudo iptables -L -n -v
as well?Tried
sudo iptables -L -n -v
and below is the output. My bin don’t seems to show much details though. Trying to a way of providing enough details.Just to give you an idea on how my settings looks like, I created my wordpress from one click install and followed the steps of this tutorial > https://www.digitalocean.com/community/tutorials/one-click-install-wordpress-on-ubuntu-13-10-with-digitalocean
For those who went through the same problems that I have to use the certificate in iremail that when trying to access the link https://mydomain.com/iredadmin, returned the error “NOT FOUND - The requested URL / iredadmin / was not found on this server.” insert rows:
example below
hello, can’t do a2enmod, tut seems to be obsolete… ubuntu 14.04
root@server:~# sudo a2enmod ssl sudo: a2enmod: command not found
any suggestions?
sorry, was trying to do this without apache installed ^_^
It should also be outpointed that the free class 1 certificate from StartCom MUST NOT be used for any commercial purpose (see StartCom Certificate Policy -> paragraph 3.1.2.1.).
So for my projects I rather use a Comodo or GeoTrust RapidSSL SSL certificate which can be found for less than 10 bucks a year, e.g. here: SSLPOINT
OK this is the part where I don’t get it
where do you upload the ssl.key to? /var/www/ ? or which folder?
Thanks!
If you want to serve through HTTPS and are using Ubuntu 14.04 (or similar), and you set up a firewall with iptables as explained in this article (How To Set Up a Firewall Using IPTables on Ubuntu 14.04), you have to open the port in iptables.
You can execute:
and then
Good instructions, however, where do I go for any problems? I need to check the log as it’s hanging on https …
Cheers,
Followed this tutorial really well. thank you. However, SSL is hanging https://www.mysite.com whilst http is working fine. View the /var/log/apache2/error.log and nothing at all to worry about, apache restarting no problems.
I did run this - echo HEAD / | openssl s_client -connect localhost:443 -quiet > /dev/null
and got this:
depth=1 C = IL, O = StartCom Ltd., OU = Secure Digital Certificate Signing, CN = StartCom Class 1 Primary Intermediate Server CA verify error:num=20:unable to get local issuer certificate verify return:0 read:errno=0
Anyone have any solution?
I followed these directions. My server is setup with multiple domains and I use ISPConfig to manage it. When I go to the domain that I already have setup with wordpress and that I used to generate the certificate, it works fine, but when I load it using https, I am getting the Apache “It Worked” page. How do I direct the domain properly to use the https on the existing site?
Thanks! Now my owncloud is completely secure :)
where in the server will i put this ssl.key thx!
(ssl.key file), but your web server needs the unencrypted version of it to handle your site’s encryption. To unencrypt it, copy it onto your server, and use the following command to decrypt it into the file private.key:
**Help! ssl.key **
unable to load Private Key 140329482557088:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: ANY PRIVATE KEY
Just to share, I’ve had some problems with the guide at the line
nano /etc/apache2/sites-enabled/000-default
For Ubuntu 14.04, it seems the file should be name /etc/apache2/sites-enabled/000-default.conf instead. This worked for me. Hope this helps someone.
Great Article !!!
Once everything is working, maybe you would like to redirect http users to https by adding:
Redirect / https://www.example.com/
to the <VirtualHost *:80>
Thank you for tutorial.
I would like to know, is it possible to use this certificates for Mail Server? If yes, could you please guide me?
Thanks! Tev.
I start by installing Magento from the one click install. After the install I came straight to this tutorial.
At the step that says to open the config file nano /etc/apache2/sites-enabled/000-default
There is no 000-default file in that folder. Only magento-ssl.conf and magento.conf. Neither of them look like they have the right content inside to be the right file.
I’m supposed to add the following at this stage but not sure where to add it. SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /etc/apache2/ssl/ssl.crt
SSLCertificateKeyFile /etc/apache2/ssl/private.key
SSLCertificateChainFile /etc/apache2/ssl/sub.class1.server.ca.pem
There is a 000-default.config file under sites-available but I don’t think that right either.
Can any one provide some advice here?
Thanks
Great guide.
Fantastic tutorial! Worked without a hitch.
What about using the certificate with nginx?
To use the certificate with nginx, you would have to concatenate ca.pem, sub.class1.server.ca.pem, and ssl.crt into one file:
and then use it as the certificate:
See:
It works perfect for me. Thanks!
You’ll be prompted to choose from an email at your domain, something like postmaster@yourdomain.com.
well… one needs the cert to setup the mailserver…so this makes no sense at all ;-)
Great tutorial !!! Thanks!!!
Comodo’s Single domain positive SSL costs next to nothing. Its given out free for an year if someone buys a domain from namecheap. It would probably be much easier for people to configure. If people loose the bootstrap certificate, then they gotta start all over.
Why is it important to use Google Chrome? Firefox is my preferred browser within linux and I’d rather not muck about with bothering to build chrome.
Thank you! :D :D
Worked perfectly. I have 7 domains on the same VPS and it worked on the one I’m using for testing. My Apache config uses the IncludeOptional sites-enabled/*.conf and different config files for each site.
Although my /etc/apache2/sites-enabled/ configuration is simpler I just copied my port:80 config to use it as port :443 adding the few other lines and worked perfectly.
Thank you!
Awesome! I got it in the first try :) Thanks a lot for this great tutorial!
I have an issue with www subdomain.
I’m trying to get certificate for like example.com (which is main mirror) On startssl I specified subdomain www.example.com (infact web-server redirects www to example.com)
So I got it installed, everything works fine. But certificate shows www.example.com domain instead of example.com (which I intended to use)
How can I change that?
I guess problem is that startssl makes subdomain as main one and puts original domain as alt-name. Can’t figure how to swap them.
What is the ca.pem used for? It is not referenced in any of the config files mentioned above.
This is just GREAT! Thank you very much for all the detailed explanations. I followed these instructions with 2 domains and got both certificates in a breeze.
There is an error in this step: Now, open your apache2 configuration file. Unless you’ve already modified the default configuration, input: nano /etc/apache2/sites-enabled/000-default
For me, the right path to find such file was: nano /etc/apache2/sites-available/000-default.conf*
And all the text showing /var/www as document root, must be changed to /var/www/html
I hope somebody could find this update useful
I’ve done everything as described above and when I connect the https://www.domain.com, browser tells me “This webpage is not available”. I haven’t understood anything “error.log” file cause it’s really complicated for me.
Which of these files do I need to save locally if in case I switch server? Which of these can be procured from StartCom website? I currently have following 5 files.
ca.pem private.key ssl.crt ssl.key sub.class1.server.ca.pem MY-EMAIL StartCom Class 1 Primary Intermediate Client CA ID
I somehow lost the client certificate that I originally installed in the Chrome browser. I suppose I need to get in touch with CertMaster.
The website went down for maintenance while I was still getting my certificates…
It went back up, I completed the tutorial and I have SSL working on my website. Thanks!
I successfully set up with this tutorial, thanks! Just one thing, the lock icon (ssl) as seen on the website is not green, but yellow with warning saying something like “The identity of this website has been verified by StartCom Class 1 Primary Intermediate Server CA but does not have public audit records.”.
If I browse this via safari on mobile, the lock icon won’t appear at all.
Do you know how can I solve this?
Hi Nik, just back to that article to say thank you, works for me and simple as 1-2-3 even for people which never registered SSL before.
This comment has been deleted
Followed this tutorial but when i want to acces my site with https:// I dont get a response, http:// is still working
Yeah I seem to be having the same problem. https://[mydomain].com and https://www.[mydomain].com both time out (“This web page is not available / ERR_CONNECTION_TIMED_OUT”), but going to http://[mydomain].com or http://www.[mydomain].com works as before.
This isn’t working for me. I followed the steps in this tutorial exactly, with the exception that I made changes to both 000-default.conf and [mydomain].com.conf, since I set that up in a different tutorial on this site (specifically, the one titled “How To Set Up Apache Virtual Hosts on Ubuntu 14.04 LTS”).
When I try to visit the https version of my site, it times out, giving a “This web page is not available / ERRCONNECTIONTIMED_OUT” message in Chrome. https://[mydomain].com and https://www.[mydomain].com both time out, but going to the non SSL http://[mydomain].com or http://www.[mydomain].com works as before.
And, for what it’s worth, neither /var/log/apache2/acces.log nor /var/log/apache2/error.log are giving any errors that I can identify as being related to this.
It looks like there’s a firewall blocking connections to port 443 (HTTPS). Are you using
ufw
by any chance? If so, run the following command to allow HTTPS connections:If not, please post the output of the following command:
Hey @kamaln7. Yeah, I actually figured it out myself a few minutes after posting this (guess I should have Googled a little more before asking for help). I had forwarded port 80 through my router ages ago, so I forgot that I also needed to forward port 443.
Thanks for the help!