Struggle to route to subdomain

Hello,
I am starting using Traefik and I a struggling to set it up. I am using docker-compose.

I have two subdomains pointing to the ip of my VPS with the following target

  • vps.labonnefabrique-point-fr (sorry I hit the limit of authorized url in a post): everything about the core vps, Traefik and something like dockProm to monitor the vps. For know, only traefik is setup and listening on 8080
  • graphql.labonnefabrique-point-fr : hasura graphql endpoind. The app exposes its ports to 8082

I read the docs and followed the tutorials of https://containo.us/blog/traefik-2-0-docker-101-fc2893944b9d/ . I succeeded in making the example " My Application Listens on a Specific Port" to work.

But I am struggling to succeed in making my case working. Here is my docker-compose.yml

  
version: "3.3"

services:
  traefik:
    image: "traefik:v2.0.1"
    command:
      - --entrypoints.web.address=:80
      - --providers.docker
      - --api.insecure
      - --providers.docker.endpoint=unix:///var/run/docker.sock
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
  postgres:
    image: postgres
    restart: always
    volumes:
     - "./db_data:/var/lib/postgresql/data"
  graphql-engine:
    image: hasura/graphql-engine:v1.0.0
    ports:
      - "8082:8080"
    labels:
      - traefik.http.routers.graphql-engine.rule=Host(`graphql.labonnefabrique.fr`)
      - traefik.http.services.graphql-engine.loadbalancer.server.port=8082
    depends_on:
      - "postgres"
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5432/postgres
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
      HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
      ## uncomment next line to set an admin secret
      # HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey

What I expected is that http://vps.labonnefabrique-point-fr-:-8080 gets to the Traefik dashboard and graphql.labonnefabrique -point- fr gets to the graphql endpoint.

What I got:

  • vps.labonnefabrique.fr-:8080/ get to Traefik dashboard but http://vps.labonnefabrique.fr-:8082/ to the graphql end point
  • graphql.labonnefabrique -point- fr/ give a bad gateway error, http://graphql.labonnefabrique.fr-:8082 leads to the graphql end point and http://graphql.labonnefabrique.fr-:8080 to the Traefik dashboard.

I don't understand what is wrong with my config. Could someone point me to the right direction?

Thanks

I made some progress by adding

exposedByDefault = false

now the graphql behave correctly. But
graphql.labonnefabrique.fr:8080 still show Traefik console. How could I forbid this behavior?

With exposedByDefault = false you are not using traefik to expose graphql, so you can remove the traefik altogether for the same result: That is if you are using different ports for exposing stuff anyway, you do not need traefik.

Note that vps.labonnefabrique-point-fr does not appear in your config at all.

Thank you for your reply it made me think. I should have precised that I added traefik.enable=true in the graphql service.

vps.labonnefabrique.fr is dedicated to traefik and monitoring (to be added). I tried to put some labels in the traefik service but it messed the config.

Anyway, you're right, I have to assess if I really need Traefik and the added complexity.
thanks

This is a simple issue to resolve: Https redirection not working when providers.docker.exposedbydefault=false

Also, look at these compose files and see how "traefik.enable=true" is activated within services.

Cheers!