본문 바로가기
WIKI 기술 지식 베이스

Traefik ContentType 미들웨어

원문 보기 위키 갱신

출처: Traefik ContentType 미들웨어 (ContentType Documentation)

본문

ContentType

contentType 미들웨어는 백엔드가 설정하지 않았을 때, 응답 콘텐츠에서 감지한 미디어 타입으로 Content-Type 헤더 값을 설정해요.

정보

contentType 미들웨어는 Traefik이 MIME 타입을 감지한 경우에만 적용돼요. 만약 체인 어느 지점에서든 다른 미들웨어(예: Headers나 Compress)가 contentType 헤더를 설정한다면, contentType 미들웨어는 아무 효과가 없어요.

설정 예시

구조화 (YAML)

# 자동 감지 활성화
http:
  middlewares:
    autodetect:
      contentType: {}

구조화 (TOML)

# 자동 감지 활성화
[http.middlewares]
  [http.middlewares.autodetect.contentType]

Labels

# 자동 감지 활성화
labels:
  - "traefik.http.middlewares.autodetect.contenttype=true"

Tags

// 자동 감지 활성화
{
  // ...
  "Tags": [
    "traefik.http.middlewares.autodetect.contenttype=true"
  ]
}

Kubernetes

# 자동 감지 활성화
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
  name: autodetect
spec:
  contentType: {}

더 알아보기 (Learn more)