Skip to content
0:00 / 0:00

#nginx#express#reverseproxy

Nginx Tutorial - Proxy to Express Application, Load Balancer, Static Cache Files

LearnCode.academy

770K subscribers • 5 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • A classic. People kept recommending it from 2014 to 2018.
  • May be out of date. Uploaded 12 years ago, in an area where tools change fast.

Beginner. No background in the topic needed.

129K views12 years ago3 recommendations

Cloud and DevOpsWeb developmentNetworking and protocolsNode.js, Deno and BunWeb performance

This tutorial demonstrates how to configure Nginx as a reverse proxy, load balancer, and static file cache for an Express application.

Nginx ROCKS! In this Nginx Tutorial, we're going to setup Nginx to receive http requests to our domain name (port 80), then proxy to our Express.js Node.js App, which is running on port 3000. View Nginx Configuration Code here: gist.github.com/learncodeacademy/ebba574fc3f438c851ae We're also going to set it up Nginx load balancing, so the http requests will get evenly distributed between all of our servers. See full documentation on Load Balancing (upstream) here: nginx.org/en/docs/http/ngx_http_upstream_module.html Lastly, we're going to setup static file caching on Nginx, so our css, js and image files are only served from our Node.js application the first time...this DRASTICALLY improves application performance. -~-~~-~~~-~~-~- Also watch: "Responsive Design Tutorial - Tips for making web sites look great on any device" youtube.com/watch?v=fgOO9YUFlGI -~-~~-~~~-~~-~-

Why it's here

3 people recommend this

What people say. Recommended as a quick and clear guide to setting up Nginx in front of Node.js for performance and scaling.

u/87658764in r/node • Recommends

On “How do I run in a directory at port 80?”

You should use nginx instead of Apache. This is how to do it in nginx. mywebsite.com/nodeapp would redirect to http://127.0.0.1:7000 http { upstream myNodeApp { server 127.0.0.1:7000; } server { listen 80; server_name mywebsite.com; location /nodeapp { proxy_pass http://myNodeApp; } } } You should also watch this: link to this video

u/lineapein r/node • Recommends

On “I've used pm2 to scale my app across cores on a single server....what's the easiest method to scale a node.js app across multiple servers?”

This video has a quick demo of setting up a nginx reverse proxy for load balancing, and also caching of static assets so grabbing images/css/etc never needs to hit the node app. Pretty easy, and a major performance boost.

u/87658764in r/node • Recommends

On “Why not run on port 80?”

You shouldn't use your node app as an actual web server. Put nginx in front of it. Related video

u/animals_of_the_worldin r/node • Recommends

On “Node.js clustering”

your correct regarding clustering. : ) to learn load balance between different servers watch this: [video