Datagerry behind Traefik Proxy

Hello to all,

i want to check if i can install datagerry for our company. For this i have a small test-environment. I want to get Datagerry working with docker-compose. For this I prepare the docker-compose file from the official Datagerry-Wiki. As an information, i use Traefik v2 to get my containers available.

The following shows my configuration of docker-compose.yml with my additional config:

version: "3.0"
services:
  nginx:
    image: nethinks/nginx:latest
    ports:
     - 8443:80
    labels:
     - "traefik.enable=true"
     - "traefik.http.routers.${servicename}.entrypoints=http"
     - "traefik.http.routers.${servicename}.rule=Host(`${Domainname}`)"
     - "traefik.http.middlewares.${servicename}-https-redirect.redirectscheme.scheme=https"
     - "traefik.http.routers.${servicename}.middlewares=${servicename}-https-redirect"
     - "traefik.http.routers.${servicename}-secure.entrypoints=https"
     - "traefik.http.routers.${servicename}-secure.rule=Host(`${Domainname}`)"
     - "traefik.http.routers.${servicename}-secure.tls=true"
     - "traefik.http.routers.${servicename}-secure.tls.certresolver=http"
     - "traefik.http.routers.${servicename}-secure.service=${servicename}"
     - "traefik.http.services.${servicename}.loadbalancer.server.port=${port}"
     - "traefik.docker.network=proxy"
     - "traefik.http.routers.${servicename}-secure.middlewares=secHeaders@file"
     
    networks:
      - proxy
      
    depends_on:
    - datagerry
    environment:
      NGINX_LOCATION_DEFAULT: "/;/;http://datagerry:4000"
    restart: unless-stopped

  datagerry:
    image: nethinks/datagerry:latest
    depends_on:
    - db
    - broker
    environment:
      DATAGERRY_Database_host: "db"
      DATAGERRY_MessageQueueing_host: "broker"
    restart: unless-stopped

  db:
    image: mongo:4.2-bionic
    restart: unless-stopped
    volumes:
      - mongodb-data:/data/db
      - mongodb-config:/data/configdb
    
  broker:
    image: rabbitmq:3.8
    restart: unless-stopped
    volumes:
      - rabbitmq-data:/var/lib/rabbitmq

volumes:
  rabbitmq-data:
  mongodb-data:
  mongodb-config:

networks:
   proxy:
      external: true

With this configuration the nginx-container is available but shows the error 502 - Bad Gateway. I’ve checked the nginx error log and get the following two lines:

2021/01/06 12:39:49 [error] 14#14: *1 datagerry could not be resolved (3: Host not found), client: 172.xx.x.x, server: localhost, request: "GET / HTTP/1.1", host: "domain.tld"
2021/01/06 12:39:49 [error] 14#14: *1 datagerry could not be resolved (3: Host not found), client: 172.xx.x.x, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "domain.tld", referrer: "domain.tld"

I’m not very familiar with the configuration of nginx. In my point of view, there is an wrong configuration with the nginx environment-variables or virtual hosts. But i dont know, how i can fix that.
Maybe someone has the same or similar error and get this construct work.
For additional information, please write me :slight_smile:

Have a wonderful day :wink:

Update and also shame on me. Found a solution:
the important point is, to tell the nginx-container, that he is also inside the “- default” network.
click here

Hi @ClepToManix

and welcome to our community! Yes, I saw that configuration problem directly when reading your post in my e-mails yesterday in the evening :slight_smile: Thanks for sharing your configuration.

In your case maybe it is interesting to use Traefik instead of Nginx and let it communicate directly with the datagerry container (the DATAGERRY WebUI is available at port 4000). So you don’t have two reverse proxy servers in a row. What do you think?

Hey @mbatz ,

thanks for your response :wink: I will check what happens if i modify that part. If it works, I will also give this as an configuration example.

Have a wunderful day :slight_smile:

1 Like