Building Data-Driven Web Apps with Flask and SQLAlchemy Transcripts
Lecture: Concept: nginx
0:00 Finally, we needed to setup Nginx
0:02 as our external server that would
0:04 internally speak to uWSGI.
0:06 So here's how we started.
0:08 We said we're going to listen on port 80.
0:10 Our domain is what we came up with.
0:12 It was fake_pypi.talkpython.com.
0:14 You'll have a better domain, I'm sure, than that.
0:16 But whatever your domain is, here's what it is
0:19 you have to set that up in DNS.
0:20 And then we map the static files
0:23 with caching and gzip and all that stuff
0:26 over from where it is on the file system to /static
0:29 and we set the cache for 365 days or one year.
0:34 All right, so this is the first part of the file.
0:35 So this is the static stuff and listening.
0:37 We'll copy this file over to
0:42 And then, in addition to that
0:43 we're going to have a location for /
0:45 that's going to take the url
0:47 and try it against our application.
0:49 Which is just to say
0:51 pass all the right parameters over as well
0:55 along to uWSGI.
0:56 And the way you get to it is through
0:58 proxy_pass localhost:5000.
1:02 That's it, we copy that file over
1:03 we restart Nginx and off to the races.
1:06 We're ready to talk to that domain.
1:08 Last thing we did was use Let's Encrypt
1:10 which rewrote this file to listen on port 443
1:14 and do a dedirect from port 80 over to 433
1:17 so we have SSL as well.