This course has been updated! We now recommend you take the Full Stack for Front-End Engineers, v3 course.

Check out a free preview of the full Full Stack for Front-Ends Part 2 course:
The "Nginx Setup: Installation" Lesson is part of the full, Full Stack for Front-Ends Part 2 course featured in this preview video. Here's what you'd learn in this lesson:

Jem starts with an overview of HTTPS, and then completes setting up Nginx while providing tips to make installation easier.

Get Unlimited Access Now

Transcript from the "Nginx Setup: Installation" Lesson

[00:00:00]
>> Jem Young: Yes, part four where it gets interesting. So we're gonna go over nginx we're gonna install that, we're gonna set it up. Talk about a little bit why on HTTPS we covered it at the tail end of the last course, but let's talk about it a little bit more.

[00:00:13] We're gonna talk about how to get a certificate aka how to get that cool lock icon then we're gonna talk about Cron, Cron jobs. Yes, Cron doesn't stand for anything as far as I know, maybe it does we'll talk about that later. So let's install nginx on our box then we're gonna proxy traffic through our node server.

[00:00:32] Then we're gonna add a domain name to nginx, then we're gonna open up port 443, that's our secure port. Then we are going to reload nginx, so I will give you a minute or two, actually give you a few minutes to catch up. And then I'll go ahead and do that with you, and make sure we are all on the same page.

[00:00:51] All right, cool. So everybody remembers how to install nginx, app sole nginx, kind of getting it now?
>> Speaker 2: But we don't wanna install it as root?
>> Jem Young: Do not install it as root. Well, you generally have to install it, anyways. You have say sudo app install nginx, but we're not gonna run it as root.

[00:01:14]
>> Speaker 2: Gotcha.
>> [BLANK AUDIO]
>> Jem Young: And inside a proxy thinks a node.
>> Jem Young: And important note, if you haven't set up your domain name to point to your new server, pretty much all the HTTPS part is gonna be lost on you because you didn't do that part. You just have to sit and admire my shiny new icon.

[00:01:41] But if not, there's some. If you're having trouble with it, just let me know. We can do a quick recap of part one on A records or C names, that exciting stuff. So while you all working, let's talk about Nginx, the difference between Nginx and Apache.
>> Jem Young: Everybody is still working.

[00:02:03] All right, everybody wanna know. I got tired. I'm full of delicious lunch. Thank you Tiana. See now, I have a lot of energy now. I'll just drink another soda.
>> Speaker 3: I'm wondering why Nginx? Why not Apache?
>> Jem Young: I'm glad you asked that question [LAUGH]. So Nginx as we talked about in the last class is a reverse proxy.

[00:02:26] I'll just show you a slide it's a sweet diagram that I made from the last class, but a reverse proxy is let's pull this diagram, yes. So a normal proxy is a bunch of things come out or they go out through a machine to the Internet, that's a proxy.

[00:02:45] So when you use a VPN that's a form of a proxy. Everybody know what a VPN is? All right. A VPN is just a way of masking your address on the Internet. Just saying instead of me being 192.168.whatever, it won't be that address but it's just a shared address.

[00:03:01] It's a good way of bouncing your IP around. So if you wanna say, I don't know, stream the olympics illegally on BBC, you can just use a VPN and exit in London, things like that. That's a proxy. A reverse proxy is what Nginx is. So it's reverse, it's taking all that traffic from the Internet to a specific machine and then proxying it to some sort of server.

[00:03:21] So it could be a node, could be MySQL, could just serve back an html page, that's reverse proxy. That's why Nginx is really really fast. Apache is more of a full fledged server. So it's a server that can handle requests, it can process PHP, it can run programs.

[00:03:38] Whereas, Nginx is much simpler. I say simpler, like in a very high-level simpler, but it's not as complex as Apache. It's generally a bit faster as well, but it's not as full-featured. So because we're running node, we're running Nginx because we don't need Apache to run node for us, node runs fine on its own.

[00:03:56] But if we're running say PHP I would use apache every time cuz it's really good at that. That help? Yes?
>> Speaker 4: I'm a little bit confused when you say it's proxy into node or whatever, what are the yellow arrows on the right what does the big yellow arrow on the left represent?

[00:04:11]
>> Jem Young: So the little yellow arrows are requests just you, me, anybody trying to get to my domain which is jammed up party. That's just all the requests coming in and they're all hitting your machine your Nginx proxy and that's just taking all those requests and then channeling them into node.

[00:04:28] Does that kind of clear it up a little bit?
>> Speaker 4: So what happens if you didn't have proxy.
>> Jem Young: It would just terminate. It would serve the default page which looks like, find it. It looks like that, serves the default welcome to Nginx page. Just kind of you're here, you're running.

[00:04:50] If you wanted to if you didn't wanna run anything complicated you could have Nginx server just static files, which we're gonna talk about a little bit. So it doesn't have to serve node if you're just doing static HTTP, or a static website, you can just serve that right out and it's really really fast.

[00:05:04] The benefit of this versus Apache is that, Nginx scales to I don't know, everybody has their own benchmark. But it's something like they can do 500,000 requests a second or something like that in one Nginx server. So Nginx is very very capable, but it's kind of no frills.

[00:05:20] It doesn't do that much for you, and we're gonna talk a bit more about how to scale Nginx if you wanted to, if you had just a massive website.
>> Jem Young: All right, so hopefully we are all at least at step four, opening the port. So I'm gonna install Nginx.

[00:05:44] Save it, okay.
>> Jem Young: Yes.
>> Jem Young: Random tip, if you're doing apt install and you're like, I'm tired of hitting yes, if you do apt install, that's why it'll automatically hit yes for you. But you know just a random tip. There's also a command I think it's on here.

[00:06:15] Yes this is an actual command. Yes just types y y y y y. It's for piping into programs your just like yes yes yes yes yes. Instead of doing that there is literally a Unix command to do that for you. That's all it does. If you type yes, you're gonna get lots of y's, unrelated to most things.