Installing SSL Certificate on EC2 Instance running Nginx

0

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!

Edit:

I found the correct file in

/etc/nginx/conf.d/

Edward144

Posted 2017-07-03T10:52:01.983

Reputation: 13

What Linux distro are you using – Sathyajith Bhat – 2017-07-03T11:00:03.370

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 – 2017-07-03T11:02:06.480

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 – 2017-07-03T18:05:54.933

Answers

0

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.

Tim

Posted 2017-07-03T10:52:01.983

Reputation: 529