Check out a free preview of the full Full Stack for Front-End Engineers, v2 course:
The "Nginx Overview" Lesson is part of the full, Full Stack for Front-End Engineers, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Jem demonstrates how to install Nginx(engine x), an HTTP and reverse proxy server that helps route proxies.

Get Unlimited Access Now

Transcript from the "Nginx Overview" Lesson

[00:00:00]
>> Jem Young: Now we get to talk about this weird word that I ran across when I was first an engineer. And I was like nginx? N-ginx? I'll save you the trouble cuz you probably read a lot and don't know how it's pronounced, it's pronounced engine-x. Which honestly in the history of software applications is the coolest name of all time.

[00:00:23] It's like, what do you work on? Nginx. What does it do? A little bit of everything. People are like whoa. Nginx is one of the most popular web servers out there. It's what we're gonna run today. The other one you've probably heard of is Apache, which is another popular one.

[00:00:41] Apache is a little bit different and it configures a lot different. But if we're using PHP, I'd be definitely using Apache, because PHP and Apache go hand in hand, they work really, really well. They go so well it's actually it's known as the LAMP stack. Anybody know what the LAMP stack stands for?

[00:01:00]
>> Speaker 2: Linux, Apache, Mongo-
>> Speaker 3: MySQL.
>> Speaker 2: MySQL and PHP.
>> Jem Young: Yep, exactly. But anyways, Apache is another one you might run into in your careers as a full stack engineer or any sort of engineer. But today we're gonna use Nginx. I love Nginx cuz it's lightweight, it is extremely fast.

[00:01:21] I'm trying to think how fast, it can handle more requests than you can throw at it than your server can handle, put it that way. It's that fast. It's a reverse proxy, it's a web server, it's a proxy server, it's a file server, it can do caching, it can do performance tuning.

[00:01:36] It can compress your file, send it out, it can handle your encryption. Nginx does a little bit of everything and honestly it's amazing software. But, we're not gonna go too deep into it today, we're just gonna use it just enough. Because we can go really, really deep where we're compressing our G-zip levels to like level three, and we're tuning our web sockets.

[00:01:56] We might do that tomorrow, depending on how well we do today, but for today, we're just gonna configure this. So the first thing we wanna do is, actually I should explain what a web server does. We have a server, we have just a basic server, the server itself doesn't do anything.

[00:02:10] In fact it doesn't even respond to requests right now, because it's not set up to do anything. So requests hit your server,
>> Jem Young: What do? We have to figure out something, we have to figure out where that request should go. Should it go to the app? Should it go to the database?

[00:02:25] Should it go to a different server entirely? I don't know, that's why Nginx is there. Nginx helps route those requests to the right thing. That's why it's called a reverse proxy sometimes, because it takes one request and it proxies it somewhere else. Versus a regular proxy which takes a bunch of requests and proxies them to one place.

[00:02:44] You'll hear it called reverse proxy most of the time, but it's really a web server, it does a lot of things. But Nginx is one the crux of one of the things we're doing today. I would say it's more important than the actual application we're building is tuning Nginx properly.

[00:03:00] So let's install Nginx.
>> Jem Young: Because we're not root anymore, we have to use sudo all the time to install new software, so sudo apt install nginx. And I'll just do that now cuz it might take a minute.
>> Jem Young: Yes.
>> Jem Young: And while that's installing random bits of trivia you don't need to know, there's a command called yes, which all it does is type y.

[00:03:33] And you're like why does that exist? We can use the man page. It just outputs anything you want, usually it's yes. So if you wanted to install a bunch of software and you didn't want to keep typing yes. You can hit apt install, pipe it to y, it'll automatically do yes for everything until it exits.

[00:03:49] Little things you didn't need to know, but you do now, you can't unknow it. All right, so then we're gonna start Nginx, so sudo service nginx start. Sudo service nginx start.
>> Jem Young: And Nginx is up and running
>> Jem Young: And so let's test this out, let's test this bad boy out.

[00:04:15] Let me copy my IP just in case my domain setup did not go through. And say, jemisthebest, whoop, jem I-S dot best. All right, it works. And this seems really simple, but remember all the steps we had to go through to configure our name servers, and get our DNS records.

[00:04:40] Then start the server and install and get our server up and running, the SSH, and we got it all running, and now we get this Nginx page. It's the little things, more importantly is you understand all the steps it took to get here. And it seems really, really simple, but you know that it's not, underneath the hood was a lot of work.

[00:04:58] Awesome, I should have shared this screenshot with you, when I bought my domain it cost me $1.80. And see that ICAN fee? Remember I talked about there's this registrar that controls all the stuff, so I don't know what this is, and so I just paid a $0.18 fee.

[00:05:10] Whenever you buy a domain, you renew it, you're always paying this little tiny fee that helps keep the Internet running. So if you're ever wondering what that is, that's why.
>> Jem Young: Awesome, is everybody seeing the Nginx page? Hopefully, if you didn't buy a domain, just type in your IP.

[00:05:24] So I can also do that and I'm gonna get the same thing.
>> Jem Young: And if I really want to get tactical, I can type in the port 80 which is the default port and I'm gonna get the same thing again. Nginx is now running on port 80, it automatically opens the firewall to port 80 for you, we don't have to do that.

[00:05:42] And tomorrow we're gonna talk about firewalls and configuring them properly, but not today.
>> Jem Young: Okay, is everybody with me? If you're not here, pretty much everything else I'm gonna say will not make any sense. Cool, so now, we asked the causing question, how does the Internet work? There's a domain, it hits a name server, the name server says, hey, I know where you're trying to go.

[00:06:04] Here's the IP, the IP gets passed off to other routers and nodes and switches, eventually hits your server. When it hits your server, it says what I do now? Nginx says, hey, I know where to go, I'm gonna route you to this default page, just a blank HTML page.

[00:06:19] That's how a lot of the Internet works so far, and we're gonna slowly build up until it gets more and more complex. Until you'll be masters, some say frontend masters.