Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
365 views
in Technique[技术] by (71.8m points)

docker - Traefik returns ""backend not found" error

I have the following Docker compose file:

version: "3.7"
services:

  shinyproxy:
    build: /home/shinyproxy
    deploy:
      replicas: 3
    user: root:root
    hostname: shinyproxy
    image: shinyproxy-example
    labels:
      - traefik.enable=true
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend=shinyproxy
      - traefik.frontend.rule=Host:analytics.data-mastery.com;
      - traefik.port=5000
      - traefik.docker.network=sp-example-net

  keycloak:
    image: jboss/keycloak
    labels:
      - traefik.enable=true
      - traefik.backend.loadbalancer.swarm=true
      - traefik.backend=keycloak
      - traefik.frontend.rule=Host:analytics.data-mastery.com;Path:/auth
      - traefik.port=8443
      - traefik.docker.network=sp-example-net
    networks:
      - sp-example-net
    volumes:
      - type: bind
        source: /home/certs/fullchain.pem
        target: /etc/x509/https/tls.crt
      - type: bind
        source: /home/certs/privkey.pem
        target: /etc/x509/https/tls.key
      - /home/theme/:/opt/jboss/keycloak/themes/custom/
    environment:
      - PROXY_ADDRESS_FORWARDING=true
      - KEYCLOAK_USER=myadmin
      - KEYCLOAK_PASSWORD=mypassword

  reverseproxy:
    image: traefik:v1.7.16
    networks:
      - sp-example-net
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
      - ./traefik/traefik.toml:/traefik.toml # Traefik configuration file
      - ./volumes/traefik-acme:/acme # Tell Traefik to save SSL certs here
    command:
      - '--docker'
      - '--docker.swarmmode'
      - '--docker.domain=analytics.data-mastery.com'
      - '--docker.watch'
      - '--accessLog'
      - '--checkNewVersion=false'
      - '--api'
      - '--ping.entryPoint=http'
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"

networks:
  sp-example-net:
    driver: overlay
    external: true
    attachable: true

This is my traefik.toml file.

debug = false

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

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
  [entryPoints.https.tls]
    cipherSuites = [
    "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
    "TLS_RSA_WITH_AES_256_GCM_SHA384"
    ]
    [entryPoints.keycloak]
    address = ":8443"  
    [entryPoints.shinyproxy]
    address = ":5000"  


[retry]

[docker]
exposedByDefault = false

[acme]
email = "langmarkus@hotmail.com"
storage = "acme/certs.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"

When I run the dommand docker-compose up and try to access the endpoints I get the following error:

"backend not found" "/" 3ms
"backend not found" "/auth" 3ms

The endpoints are not reachable. What did I do wrong? I followed an advice from another post, since I′m not very familiar with traefik and server configurations overall.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

add hostname to traefik service :

  reverseproxy:
    image: traefik:v1.7.16
    hostname: analytics.data-mastery.com
    # ...

Also, I hope you didn't run docker-compose up -d. If so, either change ..swarm=false or keep it true but run docker-compose as following:

docker stack deploy -c docker-compose.yaml data-mastery

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...