Routing dont working

I have this traefik compose:

version: "3.8"

services:
  traefik:
    image: "traefik:v2.10"
    command:
      - --entrypoints.web.address=:80
      - --entrypoints.websecure.address=:443
      - --providers.docker
      - --api
      - --certificatesresolvers.leresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
      - --certificatesresolvers.leresolver.acme.email=mail.com
      - --certificatesresolvers.leresolver.acme.storage=/acme.json
      - --certificatesresolvers.leresolver.acme.tlschallenge=true
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./acme.json:/acme.json"
    labels:
      # Dashboard
      - "traefik.http.routers.traefik.rule=Host(`traefik-dashboard.example.com`)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.tls.certresolver=leresolver"
      - "traefik.http.routers.traefik.entrypoints=websecure"
      - "traefik.http.routers.traefik.middlewares=authtraefik"
      - "traefik.http.middlewares.authtraefik.basicauth.users=user:$$apr1$$q8eZFHjF$$Fvmkk//V6Btlaf2i/ju5n/" # user/password

      # global redirect to https
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"

      # middleware redirect
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"


networks:
  default:
    name: traefik
    driver: bridge

and i have this for my backend:

version: '3.8'
services:
  postgres:
    restart: unless-stopped
    image: 'postgres:15.4-alpine3.18'
    environment:
      PGDATA: /data/postgres
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_USER: postgres
    ports:
      - '5432'
    volumes:
      - postgres-data:/data/postgres
    networks:
      - traefik
  backend:
    restart: unless-stopped
    build:
      context: .
      dockerfile: Dockerfile
    expose:
      - '8080'
    depends_on:
      - postgres
    environment:
      SPRING_PROFILES_ACTIVE: dev
      JDBC_DATABASE_URL: jdbc:postgresql://postgres:5432/postgres
      JDBC_DATABASE_USERNAME: postgres
      JDBC_DATABASE_PASSWORD: postgres
      SECURITY_USER: user
      SECURITY_PASSWORD: pass
      ADMIN_URL: url
      PRIVATE_KEY_LOCATION: "/app/resources/security/sec-private.der"
      PUBLIC_KEY_LOCATION: "/app/resources/security/sec-public.der"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.backend.rule=Host(`api.example.com`)"
      - "traefik.http.routers.backend.entrypoints=websecure"
      - "traefik.http.routers.backend.tls=true"
    networks:
      - traefik

volumes:
  postgres-data:

networks:
  default:
    external: true

and when i wanna go to api.example.com/swagger-ui/index.html i get NOT FOUND error.

Also letsencrypt certs dont work(

tls=True will enable custom TLS, but not LetsEncrypt. You need to assign certresolver to entrypoint or router.

Compare to simple Traefik example.

1 Like

Thanks! Its work for me. Also maybe you know, why spring boot admin can return white page instead login page?

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