Dhanushu Uzumaki
Dhanushu Uzumaki

Reputation: 183

Traefik - local https not working. Unable to reach server

I tried to set up reverse-proxy using traefik for one my docker-services. When I run the services, in traefik's web UI I can see the mapping but only for http eventhough I have specified https in traefik.toml file. I am also not able to access my services directly. All the services are in the same network. So I am not sure what is causing this.

traefik.toml

logLevel = "DEBUG"
defaultEntryPoints = ["https","http"]

address = ":8080"

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]
    [[entryPoints.https.tls.certificates]]
      certFile = "/certs/journal.crt"
      keyFile = "/certs/journal.key"

[retry]

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "journal.com"
watch = true
exposedbydefault = false

docker-compose.yml

version: '3'
services:
  reverse-proxy:
    image: traefik
    ports:
      - "80:80"
      - "8080:8080"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik/traefik.toml:/traefik.toml
      - ./traefik/certs/journal.crt:/certs/journal.crt
      - ./traefik/certs/journal.key:/certs/journal.key
    networks:
      - web
  prisma:
    image: prismagraphql/prisma:1.8
    restart: always
    ports:
    - "${PRISMA_HOST_PORT}:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        managementApiSecret: ${PRISMA_API_SECRET}
        databases:
          default:
            connector: postgres
            host: ${PRISMA_DB_HOST}
            port: ${PRISMA_DB_PORT}
            database: ${PRISMA_DB}
            user: ${PRISMA_DB_USER}
            password: ${PRISMA_DB_PASSWORD}
            migrations: ${PRISMA_ENABLE_MIGRATION}
  graphql-server:
    build: ./graphql-server/
    ports:
      - "${GRAPHQL_SERVER_PORT}:8080"
    volumes:
      - ./graphql-server:/usr/src/app
    depends_on:
      - prisma
    command: ["./wait-for-it.sh", "prisma:${PRISMA_HOST_PORT}", "--", "npm", "start"]
    environment:
      - PRISMA_SERVICE_NAME=prisma
      - PRISMA_API_SECRET
      - PRISMA_HOST_PORT
      - GRAPHQL_SERVER_PORT
      - APOLLO_ENGINE_KEY
    labels:
      - "traefik.backend=graphql"
      - "traefik.frontend.rule=Host:api.journal.com"
      - "traefik.enable=true"
      - "traefik.port=${GRAPHQL_SERVER_PORT}"
    networks:
      - web
  react-client:
    build: ./react-client/
    ports:
      - "${REACT_CLIENT_PORT}:3000"
    volumes:
      - ./react-client:/usr/src/app
    depends_on:
      - graphql-server
    environment:
      - GRAPHQL_SERVER_PORT
      - REACT_CLIENT_PORT
networks:
  web:
    external: true

Thanks in advance.

Upvotes: 2

Views: 2307

Answers (1)

Max F.
Max F.

Reputation: 26

Try to add following docker label to your graphql-server service:

traefik.frontend.entryPoints=http,https

I am facing the same problem. I have 'defaultEntryPoints = ["http", "https"]' in traefiks (v1.7) main config defined, but when docker containers come up and register within traefik the frontend is reachable only via HTTP, not HTTPS - unless i define the entrypoints directly via docker labels.

regards, max

Upvotes: 1

Related Questions