How to install an SSL certificate on Ubuntu for Nginx

Sky-high website security

Did you install an SSL certificate on your Ubuntu hosted server using Nginx as the Web server? If not, why risk blowing your website security? With hackers targeting businesses large and small, even Google is nudging site owners to get on board. The search engine grants a higher Google PageRank to those whose sites encrypt the transmissions with the https:// prefix. Now, that type of security requires an X.509 Digital Certificate, commonly referred to as an SSL (Secure Sockets Layer) certificate.

To get started, you’ll first need to acquire a digital certificate, then install it on a Ubuntu hosted server using Nginx as the Web server. Read on for a bit of background on the certificates and exact steps for installing.

Types of SSL digital certificates

A trusted third party called a Certificate Authority (CA) issues the three types of digital certificates: Domain Validation (DV), Organization Validation (OV), and Extended Validation (EV). The CA guarantees the digital certificate’s authenticity with a digital signature so that end users (or their software) can trust that the server is really the site it purports to be. Not sure which digital certificate is your best bet? I’ve detailed each below, listing them from least to most secure.

Domain Validation (DV)

Domain Validation certificate states that the domain is registered by someone with admin rights to the website. If the certificate is valid and signed by a trusted CA, a browser connecting to the site will inform you that it has successfully secured an HTTPS connection. A DV is all you need to secure a blog or simple website.

Organization Validation (OV)

An Organization Validation certificate validates the domain ownership and include ownership information such as the site owner’s name, city, state, and country.

Extended Validation (EV)

An Extended Validation certificate authenticates the domain ownership and organization information, as well as your organization’s legal existence. This is the go-to certificate for those engaging in e-commerce. In many browsers, you can easily identify websites with an EV SSL certificate by their green address bars.

How to secure the service with an SSL certificate

To get started, you’ll first need to purchase or acquire the SSL certificate. If needed, here are additional details on how to request an SSL certificate and verify it.

If you have purchased a CA-approved SSL certificate, delivery might take from hours for a DV to weeks for an EV. The CA will inform you when the certificate is ready for download. Here’s how to retrieve it in seven steps:

  1. Log into Account Manager.
  2. Click SSL Certificates.
  3. Pick the certificate you want to use and click Manage.
  4. Next to the certificate you want to use, in the Actions column, click View Status.
  5. Click Download.
  6. Select the server type, and then click Download Zip File.
  7. Safely store the downloaded file for the future.

How to install an SSL digital certificate for the Nginx server on Ubuntu

Installing an SSL digital certificate for Nginx won’t bust the brain. However, if you hit an obstacle on Ubuntu while running through the following steps, drop me a line in the comments section at the bottom of this post.

1. Log into the server using SSH.

2. Check the OpenSSL client software.

Make sure the OpenSSL client software needed for a secure website is in place with:

$ sudo apt-get mod_ssl openssl

This will either install OpenSSL or inform you that it’s already present.

3. Make a directory to store the server key and certificate.

$ sudo mkdir mkdir /etc/nginx/ssl

4. Copy the SSL certificate file and server key.

$ sudo cp server.crt /etc/nginx/ssl
$ sudo cp server.key /etc/nginx/ssl

5. Edit the ssl.conf or httpd.conf file.

Here’s an example using the vi text processor:

$ sudo vi //etc/nginx/sites-available/default/your_very_own_domain.com

Once open, the file can be edited so that it points to the correct files in the Web server. It will look something like:

server {
listen  80;
listen 443 ssl;

ssl on;
ssl_certificate /etc/ssl/your_domain_name.pem; 
ssl_certificate_key /etc/ssl/your_domain_name.key;

server_name your_very_own_domain.com;
access_log /var/log/nginx/nginx.vhost.access.log;
error_log /var/log/nginx/nginx.vhost.error.log;
location / {
root /home/www/public_html/your_very_own_domain.com/public/;
index index.html;
}
}

6. Restart the Web server.

Use the following command to restart the Web server:

$ sudo /etc/init.d/nginx restart

The secured site should be available at https://www.your_very_own_domain.com.

Learn about the four types of SSL certificates available.

Wildcard SSL Certificate
Extended Validation SSL Certificate
SAN SSL Certificate
Organization Validation SSL Certificate

Image by: ksr8s via Compfight cc

Steven Vaughan-Nichols
Steven J. Vaughan-Nichols (aka sjvn) has been writing about technology and the business of technology since CP/M-80 was the cutting edge, PC operating system, 300bps was a fast Internet connection, WordStar was the state of the art word processor, and we liked it. His work has been published in everything from highly technical publications (IEEE Computer, ACM NetWorker, Byte) to business publications (eWEEK, InformationWeek, ZDNet) to popular technology (Computer Shopper, PC Magazine, PC World) to the mainstream press (Washington Post, San Francisco Chronicle, BusinessWeek).