How to Configure SSL on Nginx

1.  Import your SSL to the server through FTP and unzip them in a particular directory, If you don’t have SSL you can generate Let’s Encrypt free SSL by following the below steps.

install the git package:

Debian/Ubuntu

sudo apt-get install git

RedHat/Centos

    sudo yum install git
Clone a Let’s Encrypt repository from Github Official Repository
 
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
Navigate to the clone directory
 
  sudo cd /opt/letsencrypt 
Run Let’s Encrypt with the –standalone parameter. For each additional domain name requiring a certificate, add -d example.com to the end of the command. Kindly change the domain name.
 
sudo -H ./letsencrypt-auto certonly --standalone -d cyberbuddy.in -d www.cyberbuddy.in
When prompted Agree to the Terms by pressing “A” and Type “N” for the second step. After this SSL will generate if all goes well you will get the below output 

IMPORTANT NOTES:

– Congratulations! Your certificate and chain have been saved at:

/etc/letsencrypt/live/cyberbuddy.in/fullchain.pem

Your key file has been saved at:

/etc/letsencrypt/live/cyberbuddy.in/privkey.pem

Your cert will expire on 2020-11-08. To obtain a new or tweaked

version of this certificate in the future, simply run

letsencrypt-auto again. To non-interactively renew *all* of your

certificates, run “letsencrypt-auto renew”

– If you like Certbot, please consider supporting our work by:

    Donating to ISRG / Let’s Encrypt:   https://letsencrypt.org/donate

Donating to EFF:                    https://eff.org/donate-le

2. Enable SSL Module

sudo a2enmod ssl

3. Create Virtual Host For SSL

server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name  cyberbuddy.com;
root /var/www/cyberbuddy.com/public_html;
index          index.html;
ssl on; ssl_certificate /etc/nginx/ssl-certs/nginx.crt; ssl_trusted_certificate /etc/nginx/ssl-certs/nginx.crt; ssl_certificate_key /etc/nginx/ssl-certs/nginx.key; location / {
try_files $uri $uri/ =404; } }

4. Restart the nginx service and Enjoy

sudo service nginx restart

Using the above tutorial you have learned How To Configure SSL on Nginx.

100% LikesVS
0% Dislikes

2 Comments

  • There is significantly a bundle to understand about this. I think you made certain great factors in functions likewise. Eirena Mart Wilbur

  • It’s truly a great and helpful piece of information. I am happy that you shared
    this useful information with us. Please keep us informed like this.

    Thanks for sharing.

Comments are closed.