Can't open the site via TLS

Collected my assembly traefik + apache with php + mariadb. The assembly takes place without problems. All containers start without error. Traefik opens at traefik.localhost, while the site itself at localhost takes a long time to load and gives a Gateway Timeout error. I don’t understand where I went wrong. Here are the sources.

screenshots


2021-06-11_22-12

Changed this line

traefik.http.services.egeya.loadbalancer.server.port=8085

on this

traefik.port=8085

And the site began to open. Why?

Hello @AlexanderZhirov,

Please note that the traefik.port label is from Traefik v1, and will not work in v2.

It appears that your containers are linked to multiple networks, therefore assigned multiple IP addresses by docker. You need to set the traefik.docker.network label (Docker - Traefik) to let Traefik know which network to use.

This should prevent Traefik from attempting to forward to a network it is not connected to, returning a gateway timeout error.

If adding traefik.http.services.egeya.loadbalancer.server.port=8085 worked it is because the container either:

  • Exposes no port
  • Exposes more than 1 port
1 Like

I took all the parameters in quotes and everything worked for me. I also added names to my networks.

Спойлер
version: "3.7"

services:

  traefik:
    image: "traefik:latest"
    container_name: "traefik"
    networks:
      - "traefik_net"
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.network=traefik_net"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
      - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
      - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.myresolver.acme.email=localhost@localhost"
      - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
    ports:
      - "80:80"
      - "443:443"
      # - "8080:8080"
    volumes:
      - "/var/volumes-data/letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.traefik-compress.compress=true"
      - "traefik.http.middlewares.auth.basicauth.users=test:$$2y$$05$$IXk8apZGeqyrUl.D7twc9uz1WzpQLqvlGgd66c7Oyrou0iFkqs/rS"
      - "traefik.http.routers.traefik.rule=Host(`traefik.localhost`)"
      - "traefik.http.routers.traefik.service=traefik"
      - "traefik.http.services.traefik.loadbalancer.server.port=8080"
      - "traefik.http.routers.traefik.entrypoints=websecure"
      - "traefik.http.routers.traefik.tls.certresolver=myresolver"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.middlewares=traefik-compress,auth"

  egeya:
    image: "egeya:home"
    build:
      context: .
      args:
        PHP_VERSION: "${PHP_VERSION}"
        AEGEYA_VERSION: "${AEGEYA_VERSION}"
    depends_on:
      - "egeyadb"
    container_name: "egeya"
    environment:
      - "VIRTUAL_HOST=${VIRTUAL_HOST}"
    networks:
      - "db_net"
      - "traefik_net"
    # ports:
    #   - 8085:80
    volumes:
      - "/var/volumes-data/egeya/theme:/var/www/html/themes/mytheme"
      - "/var/volumes-data/egeya/pictures:/var/www/html/pictures"
      - "/var/volumes-data/egeya/user:/var/www/html/user"
    labels:
      - "traefik.enable=true"
      - "traefik.http.middlewares.egeya-compress.compress=true"
      - "traefik.http.routers.egeya.rule=Host(`localhost`)"
      - "traefik.http.routers.egeya.service=egeya"
      - "traefik.http.services.egeya.loadbalancer.server.port=80"
      - "traefik.http.routers.egeya.entrypoints=websecure"
      - "traefik.http.routers.egeya.tls.certresolver=myresolver"
      - "traefik.http.routers.egeya.middlewares=egeya-compress"
    depends_on:
      - "egeyadb"

  egeyadb:
    image: "mariadb:${MYSQL_VERSION}"
    command: "mysqld --default-authentication-plugin=mysql_native_password"
    restart: "always"
    container_name: "egeyadb"
    environment:
      - "MYSQL_ROOT_PASSWORD=egeya"
      - "MYSQL_DATABASE=egeya"
    networks:
      - "db_net"
    ports:
      - "3306:3306"
    volumes:
      - "/var/volumes-data/egeya/mysql:/var/lib/mysql"
    depends_on:
      - "traefik"

  adminer:
    image: "adminer:latest"
    container_name: "adminer"
    # ports:
    #   - "8081:8080"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.adminer.rule=Host(`db-admin.localhost`)"
      - "traefik.http.routers.adminer.service=adminer"
      - "traefik.http.services.adminer.loadbalancer.server.port=8080"
      - "traefik.http.routers.adminer.entrypoints=websecure"
      - "traefik.http.routers.adminer.tls=true"
      - "traefik.http.routers.adminer.tls.certresolver=myresolver"
    networks:
      - "traefik_net"
      - "db_net"
    depends_on:
      - "egeyadb"
      
networks:
  traefik_net:
    name: "traefik_net"
  db_net:
    name: "db_net"

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.