Question

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

Posted May 19, 2018 1.6k views
Nginx Node.js Docker 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.

0 answers
Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!