inflearn logo
강의

Course

Instructor

How to use Docker Swarm instead of Kubernetes - Core Lecture

How to set https mode in Docker SWARM mode

404 에러

169

deo01

11 asked

0

traefik.yaml

services:
  traefik:
    image: traefik
    ports:
      - target: 80
        published: 80
        mode: host
        protocol: tcp
      - target: 443
        published: 443
        mode: host
        protocol: tcp
      - 9001:9001
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /var/log/traefik:/var/log/traefik
      - traefik-certificates:/certificates
    deploy:
      mode: global
      placement:
        constraints:
          - node.labels.traefik-public.traefik-certificates == true
      labels:
        - traefik.enable=true
        - traefik.docker.network=traefik-public
        - traefik.constraint-label=traefik-public
        - traefik.http.middlewares.https-redirect.redirectscheme.scheme=https
        - traefik.http.middlewares.https-redirect.redirectscheme.permanent=true
        - traefik.http.routers.traefik-public-http.rule=Host(`test.shop`)
        - traefik.http.routers.traefik-public-http.entrypoints=traefik-ui
        - traefik.http.routers.traefik-public-http.middlewares=https-redirect
        - traefik.http.routers.traefik-public-https.rule=Host(`test.shop`)
        - traefik.http.routers.traefik-public-https.entrypoints=traefik-ui
        - traefik.http.routers.traefik-public-https.tls=true
        - traefik.http.routers.traefik-public-https.service=api@internal
        - traefik.http.routers.traefik-public-https.tls.certresolver=le
        - traefik.http.routers.traefik-public-https.middlewares=admin-auth
        - traefik.http.services.traefik-public.loadbalancer.server.port=8080
        - "traefik.http.middlewares.non-www-to-www.redirectregex.regex=^https?://(?:www\\.)?(.+)"
        - "traefik.http.middlewares.non-www-to-www.redirectregex.permanent=true"
        - "traefik.http.middlewares.non-www-to-www.redirectregex.replacement=https://www.$${1}"
      update_config:
        order: stop-first
    command:
    - --providers.swarm.network=traefik-public
    - --providers.swarm.constraints=Label(`traefik.constraint-label`, 'traefik-public')

    #v3 버전 전용 코드
    - --providers.swarm.exposedbydefault=false
    - --providers.swarm.endpoint=unix:///var/run/docker.sock
    - --entrypoints.http.address=:80
    - --entrypoints.https.address=:443
    - --certificatesresolvers.le.acme.email=email
    - --certificatesresolvers.le.acme.storage=/certificates/acme.json
    - --certificatesresolvers.le.acme.tlschallenge=true
    - --accesslog.bufferingsize=100
    - --accesslog.filepath=/var/log/traefik/traefik-access.log
    - --accesslog.fields.defaultmode=keep
    - --accesslog.fields.names.ClientUsername=drop
    - --accesslog.fields.headers.defaultmode=keep
    - --accesslog.fields.headers.names.User-Agent=keep
    - --accesslog.fields.headers.names.Authorization=drop
    - --accesslog.fields.headers.names.Content-Type=keep
    - --log
    - --api
    - --entrypoints.traefik-ui.address=:9001
    networks:
      - "traefik-public"

volumes:
  traefik-certificates: {}

networks:
  traefik-public:
    name: traefik-public
    external: true

 

app.yaml

services:
  flask:
    image: 192.168.219.114:5000/fastapi-helloworld
    networks:
      - traefik-public
    deploy:
      labels:
      - "traefik.enable=true"
      - "traefik.http.routers.flask.rule=Host(`test.shop`)"
      - "traefik.http.routers.flask.entrypoints=http"
      - "traefik.http.routers.flask.middlewares=https-redirect"
      - "traefik.http.routers.flask-https.rule=Host(`test.shop`)"
      - "traefik.http.routers.flask-https.entrypoints=https"
      - "traefik.http.routers.flask-https.tls=true"
      - "traefik.http.routers.flask-https.tls.certresolver=le"
      - "traefik.docker.network=traefik-public"
      - "traefik.constraint-label=traefik-public"
      - "traefik.http.services.flask-https.loadbalancer.server.port=8080"

networks:
  traefik-public:
    name: traefik-public
    external: true

 

  1. stack 배포하고 test.shop 접속 시 404 에러가 발생합니다.

  2. 현재 애플리케이션 컨테이너의 포트는 8080으로 설정되어있습니다.

원인이 뭘까요??

docker ubuntu docker-swarm orchestration cloud-computing

Answer 1

0

deo01

[에러 해결]

services:
  traefik:
...
    command:
    ....
      # - --providers.swarm.constraints=Label(`traefik.constraint-label`, 'traefik-public')

위 코드 주석하니 정상적으로 접속 됩니다 (+ SSL 인증까지 완료) 이유가 뭐였을까요?

알파벤티지 sleep(5) 관련 문의

0

5

0

Jib 이미지 빌드에서 docker credential 관련으로 이슈가 있다면

1

26

1

스크립트에 대해 질문 있습니다.

1

14

1

같은 사용자가 연속된 중복 호출할 경우 어떻게 되는지 궁금합니다!

1

13

1

실전 계좌에서 운영하고 계신 분 계신가요?

1

16

2

키페어 설정

0

24

2

클로드

0

37

2

이거 지금 부터 들어도 괜찮을까요 ?? 시간이 꽤지난거같은데 .. 뭐 최신하고 아에 안맞을까요 .

0

26

1

pip install -r requirements.txt

0

44

2

자료를 다운로드후 압축을 풀때 오류납니다.

0

36

2

명령 프롬프트

0

34

2

pod kubetm/app 에서 image를 갑자기 못가져 오는거 같습니다.

1

31

2

이지지 생성 노드를 커스텀 햇는데 워드프레스에 이미지 업로드가 안됨

0

30

2

3. Node Schedule 중 pod-5가 마스터 노드에 배치됩니다.

1

42

2

volume hostpath의 강의에 관해 질문이 있습니다.

1

35

2

재고 감소와 쿠폰 발급은 왜 서로 다른 방식으로 동시성을 제어하나요?

0

44

2

누락된 소스코드가 있는 것 같아서 공유합니다.

0

32

1

n8n에서 오류가 발생했는데 어떻게 풀어야할까요?

0

36

2

소스코드즘 부탁드립니다.

0

42

1

slack 알림 연동 강의 관련

1

66

2

Docker Swarm과 Traefik을 활용한 MSA 아키텍처 설계 방식

0

199

1

질문드립니다.

0

121

1

도메인을 구매 안했다면

0

161

2

13:00

0

177

2