traefik + caddy > Gateway Timeout

2.6k views Asked by At

I try to use caddy server with traefik in a simple container. Unfortunatly i get a Gateway Timeout error when i visite the domain. I can't understand if the error is due to traefik or my container.

My docker-compose file:

version: '2'
#
# [ server stack ]
#
services:
    web:
        image: abiosoft/caddy
        container_name: caddy
        restart: unless-stopped
        networks:
            - caddy_network
        ports:
            - 2015:2015
        volumes:
            # app
            - ./localhost:/srv
            # configs
            - ./config/Caddyfile:/etc/Caddyfile
        labels:
            - "traefik.frontend.rule=Host:domain.com"
            - "traefik.port=2015"
            - "traefik.backend=domain.com"
            - "traefik.frontend.entryPoints=http,https"
            - "traefik.enable=true"
#
# [ networks definition ]
#
networks:
    caddy_network:
            driver: bridge

My caddy file:

0.0.0.0:2015
browse
gzip
log stdout
errors stderr

For information, the let's encrypt certificat is perfectly generate by traefik.

Any idea? Could it be a problem with the port config?

[edit] The traefik config:

################################################################
# Global configuration
################################################################
defaultEntryPoints = ["http", "https"]
logLevel = "DEBUG"

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[acme]
email = "[email protected]"
storageFile = "/etc/traefik/acme/acme.json"
entryPoint = "https"
OnHostRule = true
onDemand = true

[[acme.domains]]
  main = "domain.com"
  sans = ["docker.domain.com", "traefik.domain.com"] 

################################################################
# Web configuration backend
################################################################

[web]
address = ":8080"

# MD5
[web.auth.basic]
users = ["admin:xxx"]

################################################################
# Docker configuration backend
################################################################

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "traefik.domain.com"
watch = true
# Tous les conteneurs seront utilisables par Traefik
# Pour qu'il ne le soit pas, il est nécessaire d'ajouter le label "traefik.enable=false" 
# lors de la création du conteneur
exposedbydefault = false

Thank you in advance for the help.

jB

2

There are 2 answers

1
jbo On

Working solution:

version: '2'
#
# [ server stack ]
#
services:
    web:
        image: abiosoft/caddy
        container_name: caddy
        restart: unless-stopped
        networks:
            - traefik_network
        ports:
            - 2015:2015
        volumes:
            # app
            - ./localhost:/srv
            # configs
            - ./config/Caddyfile:/etc/Caddyfile
        labels:
            - "traefik.frontend.rule=Host:domain.com"
            - "traefik.port=2015"
            - "traefik.backend=domain.com"
            - "traefik.frontend.entryPoints=http,https"
            - "traefik.enable=true"
            - "traefik.docker.network=traefik_network"
#
# [ networks definition ]
#
networks:
    traefik_network:
        external: true
0
R0bertinski On

It is not necessary to open the port in that container, I meant this line, it is unnecessary and not recomended: ports: - 2015:2015