#100DaysOfWeb in Python Transcripts
Chapter: Days 89-92: Deploying Python web apps to Linux
Lecture: Concept: nginx setup

Login or purchase this course to watch this video and the rest of the course contents.
0:00 The final layer, the outer layer of our onion was Nginx. So, here's how we set up Nginx. We have a configuration file
0:08 and we have a server-level setting. There's actually, they're building up multiple ones like we can have one for port 80
0:14 one for port 443, for HTTPS, things like that but we'll keep it simple for this example. So, we say listen on port 80
0:20 and listen for the domain name billtrackerdemo.com or whatever your registered domain is, it goes there. The first part is, we wantin' to make sure
0:29 that the static requests that don't require Python don't ever make it over to uWSGI. Python is not great at serving up those files anyway.
0:37 Nginx is super good at it. It doesn't have the concurrency issues that you might run into over on the Python side.
0:44 So, let's just let all the static stuff only go to Nginx. So, we just set up this alias here over to the static folder that we're working with.
0:52 Set the expiration date, stuff like that. So, here's the first part. Listen on the port for this host name and serve up the static files.
0:59 I'm going to put that into /etc/nginx/sites-enabled/billtracker.nginx. The other part is to say we'd like to pass
1:07 all the other requests so slash after application which means go over to local host 9055 and just pass it along, get the response and return it back.
1:17 So, this will mean our Python code will be running all the other requests that don't go to /static in this particular case
1:24 and I think that's more or less how we want it. So, that's it for Nginx setup and then we just have to enable it
1:29 and it also becomes an auto-starting system daemon when we turn on our service, turn on our server all the services start up off to the races.

Talk Python's Mastodon Michael Kennedy's Mastodon