Trying to setup an nginx-proxy container for other containers particularly nodejs apps using docker-compose.

May 19, 2018 173 views
Nginx Docker Node.js Ubuntu 16.04

I am following the tutorial in this blog. According to the tutorial once the nginx-proxy and let'sencrypt is setup the other apps need the docker-compose.yml file like so to work with the proxy:

version: '3'

services:
  example-app:
    image: example/example-app
    expose:
      - 80
    environment:
      VIRTUAL_HOST: app.example.com
      LETSENCRYPT_HOST: app.example.com
      LETSENCRYPT_EMAIL: foo@example.com

networks:
    default:
        external:
            name: nginx-proxy

For my nodejs app I've setup my docker-compose.yml file as follows:

version: '3'

services:
  app:
    image: node:carbon
    expose:
      - 80
    volumes:
      - .:/home/path/to/code
    environment:
      VIRTUAL_HOST: app.example.com
      LETSENCRYPT_HOST: app.example.com
      LETSENCRYPT_EMAIL: foo@example.com
    command: npm start

networks:
    default:
        external:
            name: nginx-proxy

I've setup simple package.json and index.js files to run a Hello World app. I run docker-compose up -d, which runs without issues and adds the website. However, when I go to the domain, I get an nginx 503 error. I was wondering if anyone could help point me in the right direction, or maybe even take a different approach to this problem if needed.

Be the first one to answer this question.