Enter Your Email Address to Watch This Lesson

Your link to unlock this lesson will be sent to this email address.

Unlock this lesson and all 832 of the free egghead.io lessons, plus get Node.js content delivered directly to your inbox!



Existing egghead members will not see this. Sign in.

Just one more step!

Check your inbox for an email from us and click link to unlock your lesson.



Setup an Nginx Proxy for a Node.js App with Docker

5:40 Node.js lesson by

Learn how to setup an Nginx proxy server with Docker that sits in front of a Node.js app. You can use a proxy to control the flow of frontend requests hitting your app, as well as to achieve better performance and scalability. We'll create a sample Node.js app, configure a default Nginx configuration file for proxying web requests, build both Node.js and Nginx Docker images, and learn how to link everything up and get it running with Docker specifics.

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

Learn how to setup an Nginx proxy server with Docker that sits in front of a Node.js app. You can use a proxy to control the flow of frontend requests hitting your app, as well as to achieve better performance and scalability. We'll create a sample Node.js app, configure a default Nginx configuration file for proxying web requests, build both Node.js and Nginx Docker images, and learn how to link everything up and get it running with Docker specifics.

Avatar
David

Any ideas on how to use Docker Compose to spin up both containers? Below is my first attempt at a docker-compose.yml:

version: '2'

services:
  nginx:
    build: ./nginx
    links:
      - nodejs:nodejs
    ports:
      - "8080:80"

  nodejs:
    build: ./nodejs
    ports:
      - "3000:3000"
In reply to egghead.io
Avatar
Mark

I apologize for the belated reply. Here's a docker-compose that will run these containers. Note you need to link the node container with the app name so it's connected with the correct name the proxy can pickup.

web:
  build: ./nginx
  links:
    - app
  ports:
    - 8000:80

app:
  build: ./nodejs
In reply to David
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?