Nginx, Unicorn, and Rails1:20 with Jay McGavren
In this workshop, we're going to show you how to set up a reverse proxy between your Rails app and the Internet at large. The proxy will take requests on port 80 (which is the default used by browsers), forward them to your Rails app, and then forward the Rails responses back to the browsers that requested them. We've going to use a high-performance web server called Nginx as our reverse proxy. We'll also set up Unicorn, an HTTP server that will manage connections to your actual Rails app. Unicorn is good for your site's stability and speed.
[MUSIC] 0:00 Previously we've shown you how to run a rail server in production, mode but 0:04 that doesn't mean the app is ready for production use yet. 0:08 It can only take requests on port 3,000 for one thing, 0:12 meaning that ain't URL linking to it would have to specify port 3,000. 0:15 It's also exposed directly to the web, meaning that it's easy for 0:20 malicious parties to carry out denial of service attacks on it. 0:23 That could slow down or disable your site for your actual users. 0:26 So in this workshop we're going to show you how to setup a reverse proxy, between 0:31 the rails app and the internet at large, the proxy will take requests on port 80 0:35 which is the default used by browsers forward them to your Rails app and 0:39 then forward the Rails responses back to the browsers that request them. 0:43 We're going to use a high performance web server called NGINX or reverse proxy. 0:47 NGINX will also serve the static files on our apps public directory so 0:52 rails doesn't have to. 0:55 Well also set up a unicorn. 0:58 An http server that will manage connections to your actual Rails app. 0:59 Unicorn sets up multiple worker processes that take turns 1:04 handling requests forwarded to them by nginx. 1:07 if there's some kind of problem and 1:10 a worker takes too long to respond he gets shut down. 1:11 And another worker is created to replace it. 1:14 Unicorn is good for your site's stability and speed. 1:17
You need to sign up for Treehouse in order to download course files.Sign up