Appendix C. Setting up nginx

 

This appendix covers

  • Setting up nginx as a load balancer
  • Serving static content from nginx
  • Enabling SSL for Meteor applications

Although Node.js—Meteor’s underlying server technology—is great for handling events, it’s not optimized to handle static content such as images well. Even though it’s possible to use SSL with a Node.js application, it’s not yet possible with Meteor. The fact that Node.js is a single-threaded application that won’t take advantage of the full power of multicore processors might be enough to convince you that scaling Meteor will be complicated.

Thankfully it doesn’t require much to build a production environment for running a Meteor application that takes care of all these shortcomings. In this appendix, you’ll learn how to use the lightweight web server nginx to accomplish all you need to run a rock-solid Meteor project.

C.1. Load balancing with nginx

Some of the most popular choices for running software load balancers are nginx and HAProxy. Both are available as free open source packages, but because HAProxy is built as a load balancer and nginx is a web server that’s also capable of load balancing, HAProxy provides more advanced features should you need them.[1]

1Note that the commercial variant nginx plus offers more advanced functionality, but it’s not available as open source. More details on the differences between the free and the paid versions of nginx can be found at http://nginx.com/products/feature-matrix/.

C.2. Configuring as a load balancer

C.3. Serving static content with nginx

C.4. Setting up SSL with nginx