Přeskočit na obsah
  1. Home
  2. Help
  3. TLS certificate installation
  4. TLS certificate installation on an Nginx server

TLS certificate installation on an Nginx server

This help article describes how to install an TLS certificate on an Nginx server and then configure it.

Create a key file

The issued TLS certificate is delivered by email. The certificate arrives in text form encoded in Base64 format. Change the extension to .crt and copy the file to your server.

The Intermediate certificate, which you need for the certificate's trust, must be joined to one file with the leaf TLS certificate. This is the difference between Nginx and other servers, such as Apache.

Combine the two files (certificate and intermediate certificate) into one PEM file with the following command:

cat intermediate_cert.crt >> leaf_ssl_certificate.crt

The server certificate must go in the file first, followed by one or more intermediate certificates.

Server configuration

Now you need to edit the virtual host file of the Nginx server. Open this file and edit it.

server {
    listen 443;
    ssl on;
    ssl_certificate /etc/ssl/joined_certificates.pem;
    ssl_certificate_key /etc/ssl/private_key.key;
    server_name your.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.domain.com/public/;
        index index.html;
    }
}

Note: the ssl_certificate file is a combination of the certificate and intermediate certificate, see the procedure above.

Restart the Nginx with command:

sudo /etc/init.d/nginx restart

Is everything alright? Check the certificate installation in our simple tool. For more information read the article Check installation of TLS certificate.

Are you lost?

If you're unsure about any step, please don't hesitate to contact our customer support, who will advise and help you.