What's going on guys it is Bernardo from the BTNHD and today is all about nginx and HTTPS,
and configuring it, so let's get right into it.
Alright so configuring a SSL certificate within your nginx, so you can have an HTTPS secure
sites, and this is how I configured it or this is how I taught myself on how I configured
it because I'm learning how to use nginx I open up my terminal, and within the terminal
I gave myself sudo Su, because I want to give myself root access, I know it's not best practice,
but I just don't want to get into sudo every time.
So I hit Enter, provided my password and now I am logged in as a root within terminal so
I open up my browser, and you see that nice little lock with the slash, if I click on
it, connection is not secure.
Now at the very end of the video, it's going to show that the lock is going to change.
So, back inside the terminal, I am going to do a which open SSL.
And the reason why I'm doing this to make sure that I have open SSL installed.
If you do not have it installed, you can run the following command, and just hit Enter,
and it's going to install it for you.
Pretty quick for me because I already had an install so next right now I'm going to
run the following command to create my key, as well as a CSR.
CSR stands for certificate signing request.
Yes, we need that gibberish within that file so we can go inside like GoDaddy or whatever
site that you're going to request a SSL certificate to attach that gibberish into there so they
can generate a SSL certificate for you once you hit into here, it's going to start asking
you a couple of questions just fill it out.
And once you're done.
Good to go.
Now from here.
We are going to type in the following, because we need to get inside that CSR file.
And this is the gibberish that I was talking about, we need to copy everything.
head over to the website that you're going to request your SSL I'm actually using Namecheap
because then pretty affordable from here I'm going to paste that CSR in the next.
Now when I hit next, it's going to say okay your primary domain is changing I'm changing
my SSL certificate I'm reissuing another one.
I'm changing the name to nginx.btnhd.com so I click on change, click next here, pick what
type of server, I pick any other server because I'm using nginx and then click next here.
You're going to get a confirmation email.
Now these steps that I'm going over with you guys is might be different depending on what
service that you're using now from here I'm going to click Next I'm going to get an email,
and I need to approve it.
Once I approve that information I'm able to go inside the site and download my SSL certificate.
So, that's what I did here.
And within the terminal command, I ran the following I changed the path to go inside
downloads, and I did it list command.
And there goes the zip file now that zip file we need to unzip it, so I use the following
command, I hit enter, so I'm basically extracting everything inside the zip folder and placing
it inside the Downloads folder, then I'm going to run a command to list the directory.
And there goes my files.
Now, when I was doing my research with nginx and how to configure SSL it basically said
that I had to run in CAT of the CRT as well as the CA bundle, and then move it over to
a new file, basically combine those two files into one.
That's not the case that is wrong.
It did not work.
Okay, so I'm telling you right now, if you go online and you find this information to
CAT the CRT as well as the CA bundle file into one file it's not going to work.
Okay, so the way that I got it to work is the original CRT file that I got inside that
zip file, I did a copy.
Now copying that particular file the original CRT inside the SSL certs folder.
Right.
Once you copy that file inside the certs folder you're good to go.
Now, next thing that we need to do is configure our configuration file.
Alright, and hit enter. and we need to do a couple of modifications within our virtual
host file for our site.
Now, first thing that we need to do is add the server attribute to listen to 80 default
server.
And we also do an a return of 301 with the particular parameters, and then within their
original server node, make sure that you're listening to 443, by default, it was listening
to 80 now we are changing into 443 and also adding SSL now within this server node we
are also adding the particular parameter of SSL underscore Certificate.
And the following path of where that CRT is located Now we also calling out the SSL underscore
certificate underscore key.
And wherever you drop that key, call it out.
And then last but not least within the server name I added nginx.btnhd.com save that file.
Once you save that file go back here you're going to run the following command of nginx
with a parameter of dash T, you're going to hit Enter, and that command what it does it
just checks the configuration file to see if it's up and running, if it's good to go.
Then the next command is to reload the nginx once your nginx is reloaded, open up your
browser and then type in your you know your web address now for my web address, it was
nginx.btnhd.com I hit Enter, it's going to go and do the loopback IP address the reason
that it is doing that is because that address is not actually assigned to like GoDaddy.
And I'm not actually assigning it a public IP address, everything is internal, but if
you look at the little lock its changed.
If I click on the lock.
It says connection is not secure, right, but again because I'm doing everything internally.
If I click on that, it takes me here and if I click on More information if you look closely,
it's verified by namecheap so that's good and looks like the certificate was assigned
to the site with no problem.
And it's also being redirected to HTTPS which is good, and that's it guys hopefully you
guys enjoy this video make sure to hit that thumbs up, smash that subscribe button also
do not forget to by hitting that notification bell to get the latest and greatest from this
guy and I catch you guys on the next one.
Peace out.