Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: Deployment
Lecture: Configuring nginx

Login or purchase this course to watch this video and the rest of the course contents.
0:00 I'm pretty sure we already have Nginx installed Let's just double check here. It's already there, already set up, everything is good.
0:08 Great, so what we have to do is we have this other Nginx file and let's look at it really quick. It says you're going to listen on port 80.
0:16 You're going to listen to this, we can even put things like www that, and so on. As many domains, names or subdomains as you want up there
0:25 we're just going to listen on this main one. Put a few limits, and configuration there, and then it says
0:30 Nginx itself is going to handle all of our static files our CSS, our JavaScript, everything. And it's going to find those right here
0:38 and it's going to actually cache them for a year which is pretty sweet. And then what it's going to do, it says
0:43 look, if somebody goes anywhere other than /static we're just going to go and pass that URL on to here. This is exactly how we've configured uWSGI
0:54 already so just to confirm, perfect. So it's just going to delegate that across. It's also going to pass the real IP and host name
1:04 because that stuff gets lost in this configuration if you don't pass it through that's a new header you got to ask for.
1:10 So this should be good and what we're going to do is where going to remove any default website that Nginx may have and we're
1:16 going to give it this one instead. Be careful about doing that if you care for it being there but we've gotten rid of it
1:24 'cause we don't want to use it, we don't care. Go like this, and now last thing to do is just update Nginx like we did in uWSGI
1:32 just start as a service. And restart it or start it if it's not running let's see about this, http://localhost. Boom. It's working.
1:43 You know what we can do now? We can do better than that, we can come over here and say HTTP:// I think I call it. Bam, there it is.
1:55 It's up on the internet, let's go log in. Yeah I know it's not secure. There's my account. The reason it already exists is we copied
2:04 that SQLite database so it was already there. Isn't this cool? Look how quick and speedy this thing is. If we come along let's do a little
2:15 inspect element with the network and just look at HTML. So if we hit this a few times our ping time is around 30 to 40 milliseconds
2:23 and the response time all the way back here to my browser is 50 milliseconds. That is super, super sweet. So really really digging it
2:32 looks like our server is up and running. Let's just do one more thing just to prove everything is good, let's just reboot the server
2:38 and make sure it all comes back. There's nothing we have to do, we've already done it I just want to show you that it's all configured.
2:51 There we go it's alive, let's see if it still works as we click around, account, yeah it looks live to me. Let's logout, bam, just like that.
2:59 Our server is up and running and there's a lot of details in these files here but nothing magical and I'm giving them all to you
3:08 and they're ready to just take them and configure your server and your app as you see fit.

Talk Python's Mastodon Michael Kennedy's Mastodon