Unable to set HTTPS using LetsEncrypt in Nginx server

非 Y 不嫁゛ 提交于 2020-01-16 05:46:25

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/49028071/unable-to-set-https-using-letsencrypt-in-nginx-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!