I need some help installing a renewed ssl certificate on our EC2 instance which is using Nginx. I have never used Nginx before so I want to make sure that nothing goes wrong.

I have both the certificate and Intermediate certificate (from Gandi.net) and I have been trying to follow a guide by Digital Ocean for installing them, however on the guide it mentions editing /etc/nginx/sites-enabled/default. The server doesn't have a sites-enabled directory so where should I be looking instead to add the relevant information?

If anyone can provide me with a simple step by step on installing certificates to nginx that would be highly appreciated. Thanks!


I found the correct file in


  • What Linux distro are you using
    – Sathyajith Bhat
    Jul 3 '17 at 11:00
  • It is amazons own, I forget what it is called. But the login is ec2-user. I've only just taken over managing the server so I don't have all the details, sorry
    – Edward144
    Jul 3 '17 at 11:02
  • In that case, you'll need to replace editing files in /etc/nginx/sites-enabled/default with /etc/nginx/conf.d, rest should be the same
    – Sathyajith Bhat
    Jul 3 '17 at 18:05

The first step is to find the configuration file that runs your site. It will be defined in /etc/nginx/nginx.conf, or that file will reference another file or folder that defines the server block that runs the site.

You could also use a command similar to this to find the files that it could be in

grep -R "ssl_certificate" /etc/nginx

Once you find the file you need to look at ssl_certificate directive. That points to the file that contains the certificate. You should save the new certificate in a similar location to the old one, run "nginx -t" to test the config, then reload/restart Nginx.

You may or may not need to update the ssl_certificate_key if you have a new key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.