independent full stack developer

/ Developer's blog

How to add SSL certificate to nginx for FREE

Thursday, November 21, 2024

Firstly we have to issue certificates, I use this service to get it done. https://www.sslforfree.com you just enter a domain name for which you need a certificate and then download the archive with certificates. The next step is compiling contents to one bundle.crt and tweak a host for nginx.

1. Download the archive with certifcates

2. Extract it

3. Compile files certificate.crt and ca_bundle.crt to one file, you can use cat command or just open them with text editor and copy/paste under each other with new line.

4. Upload certificates to server, eg. to folder /etc/nginx/ssl

5. Add the next to your host file

 

server {
    listen 80;
    server_name example.com;
    return 301 https://example.com$request_uri;
}

server {

        listen 443;
        server_name example.com;

        ssl on;
        ssl_certificate /etc/nginx/ssl/bundle.crt;
        ssl_certificate_key /etc/nginx/ssl/private.key;

        ...

}

 

2118 people already saw it