The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

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

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

5:40
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.
Watch this lesson now
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?