inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

쿠버네티스 대신 도커 SWARM 사용 방법 핵심 강의

도커 SWARM 모드에서 https 모드로 설정하는 법 안내

404 에러

162

앙앙기모

작성한 질문수 11

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

답변 1

0

앙앙기모

[에러 해결]

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

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

Int 값들 null 처리

0

10

1

db table 관련질문

0

15

1

제미나이 api 연결오류

0

17

2

postgres-1에 minio에서쓸 meta data 속성이 왜저장되나요?

0

18

1

현업에서 prisma relationMode는 사용안하나요?

0

19

1

유튜브 시연 영상 추가 기능 강의 업로드 계획

0

15

1

도커 GUI 툴, 포르테이너 설치

0

21

2

config 밑에 이미 파일 많이 들어가 있는데요.

0

33

3

관리자 페이지 질문

0

21

1

aws 로드 밸런서가 생성되지 않습니다.

0

26

3

안녕하세요, Oracle Cloud Free Tier 가입 과정에서 계속 오류가 발생해 문의드립니다.

1

59

2

민구님 설치시 또 막혀서 질문드려요

0

34

2

git clone 명령어를 어디 터미널에다 붙여넣어야 하나요?

0

37

2

html 파일을 못 불러 옵니다.

0

35

2

twitterdb 연결이 안돼요

1

30

2

macOS에서 Windows 실행하는 프로그램

1

30

2

이제 인프런에서 강의 더 안산다. 후져....

0

47

2

소스코드 어디서 다운받아요?

0

63

5

Docker 환경

0

72

2

Windows localhost:30000 연결 거부 현상

0

54

2

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

0

183

1

질문드립니다.

0

111

1

도메인을 구매 안했다면

0

146

2

13:00

0

171

2