Question

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

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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Did you ever figure out a solution to this? I just tried to follow the same blog and ran into the same issue.