Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set HTTPS using LetsEncrypt in Nginx server

I followed the following tutorial to set https for my website on DigitalOcean: https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04

But, I got stuck at this place - Step 6 — Securing your Application with TLS

include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;

There are no ssl-*.conf in my snippets folder to match the lines in the above conf file for TLS. I did not see any other errors up to this point. I can view my site with Http, but not HTTPS.

The command sudo nginx -t yields:

nginx: [emerg] open() "/etc/nginx/snippets/ssl-example.com.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/example.com:13

Yes, those files aren't there. So, I guess the tutorial skipped the step that generated those files.

The command ls /etc/nginx/snippets yields:

fastcgi-php.conf
snakeoil.conf

Clearly the ssl-*.conf files are missing.

Please help. I tried the DigitalOcean community for help, but didn't receive any help.

Thanks in advance.

like image 382
ubuntugod Avatar asked May 20 '26 07:05

ubuntugod


1 Answers

Ok, After researching about this for some time I found the solution myself.

We have to create those files(configuration snippets) ourselves.

We first create the configuration snippet file:

sudo vim /etc/nginx/snippets/ssl-example.com.conf

Then we add in our SSL key and certificate locations inside this file:

ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

Now, we add in the encryption settings to the second snippet file after creating it:

 sudo vim /etc/nginx/snippets/ssl-params.conf

The setting can be easily added following this link.

Once this file is saved, all we have to do is modify the Nginx configuration file.

like image 87
ubuntugod Avatar answered May 22 '26 10:05

ubuntugod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!