1

I want to serve 5 different websites, each has it's own docker image on dockerhub and I want to serve all of them with one docker-compose.yml file. The tools I am using are: - nginx-proxy - letsencrypt-nginx-proxy-companion

And I want to 1. Use docker-compose and nginx-proxy to serve all the websites - each with a unique domain name 2. Use docker-compose and letsencrypt-nginx-proxy-companion

I've managed to successfully complete step #1 with this docker-compose.yml:

version: '2'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  changed-site1:
    image: changed-user/changed-site1:v0.1.0
    environment:
      - VIRTUAL_HOST=changed-site1.com
  changed-site2:
    image: changed-user/changed-site2:v0.1.0
    environment:
      - VIRTUAL_HOST=changed-site2.com
  changed-site3:
    image: changed-user/changed-site3:v0.1.0
    environment:
      - VIRTUAL_HOST=changed-site3.com
  changed-site4:
    image: changed-user/changed-site4:v0.1.0
    environment:
      - VIRTUAL_HOST=api.changed-site4.com
  changed-site5:
    image: changed-user/changed-site5:v0.1.0
    environment:
      - VIRTUAL_HOST=changed-site5.com

when I run 'docker-compose up' everything works well but there is no SSL.

I'm now trying to complete step #2 and each of my sites are giving me a 502 error. And SSL is working on none of them. This is what my docker-compose.yml file looks like:

version: '2'

services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - dhparam:/etc/nginx/dhparam
      - certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    network_mode: bridge

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: nginx-proxy-le
    volumes_from:
      - nginx-proxy

    volumes:
      - certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    network_mode: bridge

    changed-site1:
      image: changed-user/changed-site1:v0.1.0
      environment:
        - VIRTUAL_HOST=changed-site1.com
    changed-site2:
      image: changed-user/changed-site2:v0.1.0
      environment:
        - VIRTUAL_HOST=changed-site2.com
    changed-site3:
      image: changed-user/changed-site3:v0.1.0
      environment:
        - VIRTUAL_HOST=changed-site3.com
    changed-site4:
      image: changed-user/changed-site4:v0.1.0
      environment:
        - VIRTUAL_HOST=api.changed-site4.com
    changed-site5:
      image: changed-user/changed-site5:v0.1.0
      environment:
        - VIRTUAL_HOST=changed-site5.com

Any idea what I did wrong in the second docker-compose.yml file (the first one was working).

user1227793
  • 305
  • 1
  • 4
  • 14

1 Answers1

1

I think that first of all your changed-site*: is indented to far. They should have the same indentation as the letsencrypt: container.

Secondly, if you want to use the nginx proxy companion, you must provide for each container also the LETSENCRYPT_HOST as environment variable, which is also explained on his github (https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion)

Hope this helps.

Regards!

Doubie93
  • 11
  • 1