inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Bài giảng cốt lõi về cách sử dụng Docker SWARM thay vì Kubernetes

Hướng dẫn cách set https mode trong Docker SWARM mode

404 에러

192

deo01

11 câu hỏi đã được viết

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

Câu trả lời 1

0

deo01

[에러 해결]

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

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

제미나이 대신 클로드

0

25

1

ubuntu 18.04 다운로드 링크 삭제

0

26

2

intellij나 파이참 기준 어떻게 하는지 궁금합니다

0

29

2

Jib 빌드가 83%에서 멈추는 문제 해결(windows 사용자)

1

32

1

운영환경에서의 secret 관리

0

38

2

7강 설치 질문

0

38

2

ClusterIP 실습 시 Connection refused

0

43

2

제공된 스크립트를 어디서 받을 수 있나요?

0

36

1

트랜잭션 내 Redis I/O 에 대한 궁금한점

1

37

1

Alpha vantage 유료화?

0

82

2

colab 작동

0

64

2

virtualbox 설치시

1

47

1

실행중인 컨테이너를 모두 삭제하는 방법(윈도우버전)

0

71

3

winpty docker 설정

0

63

3

vs code설치했는데도, easy docker 파일 열기에서 vs code 아이콘은 안보여요

0

44

1

[클라우드 설정 중 앞 내용 문의 사항]

1

45

1

https:// studio.opentofu.click 로 접속이 안돼요

0

49

2

aws 계정 생성 질문

1

72

1

verify.sh 4단계 실패 — Jenkins 컨테이너에서 127.0.0.1:6443 connection refused

0

64

2

베개머리투자법 섹션 5를 듣고 질문드립니다.

0

65

2

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

0

215

1

질문드립니다.

0

139

1

도메인을 구매 안했다면

0

193

2

13:00

0

205

2