0

I have a docker swarm cluster where I'm trying to setup mongodb using traefik. Traefik is working with my other services, but I'm having trouble with mongo. I try to connect with mongo compass and I usually get a "connect ECONNREFUSED" error. I'm not sure what I'm missing to get this working.

Traefik docker compose:

"--entrypoints.mongo.address=:27017"

Mongo docker compose:

version: '3.8'

networks:
  default:
    external: true
    name: proxy
    
services:
  mongo:
    image: mongo:5.0.6
    volumes:
      - /data/mongo:/data/db
    deploy:
      labels:
        - 'traefik.enable=true'

        - 'traefik.tcp.routers.mongo.rule=HostSNI(`example.com`)'
        - 'traefik.tcp.routers.mongo.entrypoints=mongo'
        - 'traefik.tcp.routers.mongo.tls=true'
        - 'traefik.tcp.services.mongo.loadbalancer.server.port=27017'
Justin
  • 67
  • 7

1 Answers1

0

Seems like there are some issues with using a specific SNI with TCP without having tls enabled and it works if you use a wildcard for the SNI like this:

traefik.tcp.routers.mongo.rule=HostSNI('*')

However if you have traefik.tcp.routers.mongo.tls=true which seems to be your case you also need to enable the SSL capability on the mongodb container and have it setup with it's own certificates that you need to use in compass / robo3t for a succesful conection.

I'm not sure how to bypass the drop of tls and the use of the wildcard in order to get this working.

HUN73R
  • 23
  • 4