Adding let's Encrypt SSL on Ngnix (@DO)

Hi, I’m having problems installing ssl certificate on my digitalocean vps running grav. I assume I have to add the ssl to my grav server block (not default). So, I think my issue is /etc/nginx/sites-available/grav. Below my /etc/nginx/sites-available/grav where my domain replaced by example:

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

    # SSL configuration

    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;
    include snippets/ssl-example.com.conf;
    include snippets/ssl-params.conf;
	
    ## Begin - Index 
    # for subfolders, simply adjust the rewrite:
    # to use `/subfolder/index.php`
....

Anyone able to help?

I believe you need something like this within your second server block

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

running “sudo ngix -t” test results in error from duplicate ssl_certificate if I add those two lines in. :confused: The same directive comes from the snippets/ssl-example.com.conf… hmm

in that case, try removing then snippets

I got it working by removing the “default_server” part but it only works for subdomains for some reason now…

You could always try taking a look at this https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04

That’s what i used when I used nginx

Thanks, I got it running perfect now. Used the same but for 16.04. Thanks for the help Vivalldi!

No problem! Welcome to Grav!