This course has been updated! We now recommend you take the Full Stack for Front-End Engineers, v2 course.
Transcript from the "Exercise 14: Nginx configuration" Lesson
>> Jem Young: This is a way of looking at the Nginx default configuration for the server or for the reverse proxy. So you can cat, but cat just jumps everything out into the terminal. It's not terribly useful so I prefer to use less. Less is another way of looking at a file except it will only give you page by page.
[00:00:19] It's much more useful than cat. So just a refresher, cat dumps everything, less gives you more page by page. It's much more useful. So go ahead and go to sudo less /etc/nginx/sites-available/default on your server, and I'll go ahead and do that on my end. So clear, sudo less /etc/nginx/sites-avalable/default.
[00:00:50] And you should have been nginx configuration and it should look exactly like this cuz it's the default configuration. Okay, everybody with me so far? Yeah, it's kind of ugly, it's got a lot of, I don't know, weird comments in here that you might not understand. But, Nginx is, why we're using it, it's A, it's extremely powerful.
[00:01:15] It's very configurable. And it's fast. It is extremely fast. Nginx can handle millions and millions of connections on sometimes a single server, and that's why we're using Nginx. You can also use Apache, Apache is a different type of server. Apache can actually serve files directly, similar to Nginx but it's more of a server where as Nginx is more of a reverse proxy is generally the differences but anybody's ever heard of a LAMP stack?
[00:01:44] So Linux, Apache, MySQL and PHP. Apache and PHP go very well together, and so if your running PHP, you're likely running Apache. But, we will focus on that but you're also free to install Apache on your server but I prefer Nginx. It's so fast and it's really, really, really configurable.
[00:02:04] I won't say it's easy to use cuz it's a little tricky but, it's very configurable.
>> Jem Young: Actually, I'll spend a little bit of time so,
>> Jem Young: I can actually. Oops, Q to quit. I am gonna VI into this, so I can edit it. You do not have to do this.
[00:02:27] I'm just gonna kinda clean up some of these lines. And just gonna delete the comments out of here.
>> Speaker 2: Blue is really hard to read.
>> Jem Young: Yeah, that's a good point. Don't worry about the comments for now.
>> Jem Young: The main, actually leave that alone. No, I'm good. The main thing you wanna worry about here is the server block.
[00:02:59] The server block, it's called block cuz it's just server in brackets. And this is one of your servers, so you can have multiple servers in an Nginx config. As in, if I go to on my website, personal website, blog.jemyoung.com, it has it's own server configuration. Just like different parts of my site, I run different types of servers.
[00:03:19] And Nginx, you can put them all in one file you can split them all across files and it's really easy to use and it's so simple looking at it. You're like, this is the server. Yes, this is the server, so this is your default block. So we're in our server.
[00:03:32] We're listening to port 80. Port 80 is the internet server, that's what you connect to in your browser. So if you go to your IP Address Port 80, it's just gonna take you straight to the Nginx page, cuz that's default. Port 443 is the SSL port. You don't have to worry about this, cuz browsers do this automatically for you, but it's just good to have these things in the back of your head.
[00:03:52] So this is my default server, it's listening on Port 80. And it's called Default Server. And it responds to different paths. So in this case, when I go to.
>> Jem Young: When I go to this, this is actually the equivalent of slash, and Nginx is responding with This 404 page, it's just the fall back page.
[00:04:16] So if I wanted to edit this, don't do this yet, it's just a demo. If I edit this and go to /foo, I can now make all requests go to /foo. I can make that respond to something else. So we're gonna edit this in a second, I just want everybody to kinda start getting familiar with Nginx.
[00:04:32] It's a little intimidating to look at cuz it's very strange syntax, but we're gonna do some very minor modifications, but I just want you to familiar Nginx works and how the server configuration works. So, just gonna exit out of here. Quit bang, cuz I didn't save anything.
>> Jem Young: So now, we've learned a little bit more.
[00:04:59] [LAUGH] It has taken many hours, but now we're getting down the internet stack. So now we know we have a domain, resolves to an IP, the IP resolves to a server, Nginx or Apache. This is where we're currently at right now. But in an interview if you got this far and you knew all this I'd be pretty impressed.
[00:05:18] Anybody having trouble so far?
>> Speaker 3: If they're seeing the 400 of an Nginx page, is that just the DNS propagation?
>> Jem Young: Yeah, cuz I get that on jem.party as well, but if you choose your IP address, it should resolve to an Nginx/Apache.
>> Speaker 4: You wanna tell them about the dig?
[00:05:35] The dig command?
>> Jem Young: Dig? I'm not familiar with that one.
>> Jem Young: Tell us.
>> Speaker 4: I'll put it in the chatroom.
>> Jem Young: Okay.
>> Speaker 4: [LAUGH].
>> Jem Young: I believe someone asked earlier how to see domain resolutions so I believe. Oops, I'm a little rusty on this one but I believe I can do nslookup on we'll say jemyoung.com and it should tell me where things are pointed.
[00:06:01] So let's see if jem.party is up yet. I really should've, every time I say it it's just.
>> Speaker 2: It's so awesome I'm glad you did that. We're gonna have a jem.party after this workshop.
>> Jem Young: Okay.
>> Speaker 2: [LAUGH] And we'll list the workshop or the party info on jem.party.
>> Jem Young: Just a gif of me going.
>> Jem Young: Where am I, where am I.
>> Speaker 2: [INAUDIBLE] We need a gif creator, and make that.
>> Jem Young: So this should resolve correctly as well, so they both work, jem.party and www.jem.party both resolve correctly. And again, if you wanna see, whoa, how did I do that?
[00:06:39] If you wanna see, nslookup is some nice commands. You don't necessarily need it, but just showing where the domain is pointed.