SNI
SNI (Server Name Indication)
SNI는 여러 호스트 이름을 하나의 인증서에 매핑하는 데 사용돼요. Kong Gateway가 클라이언트 요청의 호스트 이름에 따라 적절한 SSL/TLS 인증서를 선택할 수 있게 해 주고, 와일드카드와 우선순위 매칭을 지원해요. 이 기능을 통해 하나의 게이트웨이에서 여러 도메인을 안전하게 서비스할 수 있답니다.
출처: 문서
본문
SNI란 무엇인가요?
SNI(Server Name Indication)는 여러 호스트 이름을 인증서에 매핑하는 데 사용돼요. 이를 통해 Kong Gateway는 클라이언트 요청의 호스트 이름을 기반으로 사용할 SSL/TLS 인증서를 선택할 수 있어요. 이 기능은 여러 도메인이 동일한 게이트웨이를 통해 안전하게 제공될 수 있도록 보장해요.
SNI 라우팅
HTTPS, gRPC 또는 TLS와 같은 보안 프로토콜로 Route를 구성할 때 SNI를 라우팅에 사용할 수 있어요. SNI는 TLS 핸드셰이크 과정에서 결정되며 연결 기간 동안 변경되지 않으므로 Route 구성에 정의된 Header와 관계없이 모든 요청에 동일한 SNI가 포함돼요. 라우팅 우선순위가 할당되는 방식에 대한 자세한 내용은 표현식 라우터 문서를 읽어보세요.
와일드카드
SNI 구성에 유효한 와일드카드 위치는 다음과 같아요:
mydomain.**.mydomain.com*.www.mydomain.com
이는 TLS 경로를 구성할 때 특히 유용해요.
우선순위 매칭
SNI를 인증서에 매칭하는 우선순위는 다음 순서를 따라요:
- 정확한 SNI 매칭 인증서
- SNI 접두사 와일드카드로 인증서 검색
- SNI 접미사 와일드카드로 인증서 검색
- SNI
*와 연결된 인증서 검색 - 파일 시스템의 기본 인증서
SNI 설정하기
decK
_format_version: "3.0"
certificates:
- id: 2e013e8-7623-4494-a347-6d29108ff68b
cert: |-
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
key: |-
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY
snis:
- name: example-sni
{: data-file="kong.yaml" data-tool="deck" }
Admin API
SNI를 생성하려면 Admin API의 /snis 엔드포인트를 호출하세요.
curl -i -X POST http://localhost:8001/snis/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "example-sni",
"certificate": {
"id": "2e013e8-7623-4494-a347-6d29108ff68b"
}
}
'
Konnect API
SNI를 생성하려면 Konnect control plane config API의 /snis 엔드포인트를 호출하세요.
curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/snis/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "example-sni",
"certificate": {
"id": "2e013e8-7623-4494-a347-6d29108ff68b"
}
}
'
다음 플레이스홀더를 자신의 값으로 바꾸는 것을 잊지 마세요:
region: Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요.KONNECT_TOKEN: Konnect 계정과 연결된 개인 액세스 토큰(PAT)이에요.controlPlaneId: 컨트롤 플레인의id예요.
지역별 URL 및 개인 액세스 토큰에 대한 자세한 내용은 Konnect Control Planes Config API 참조를 확인하세요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongSni
metadata:
name: example-sni
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
name: example-sni
certificate:
id: 2e013e8-7623-4494-a347-6d29108ff68b
" | kubectl apply -f -
Terraform
전제 조건: 개인 액세스 토큰 구성
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
다음을 Terraform 구성에 추가하세요:
resource "konnect_gateway_sni" "my_sni" {
certificate = {
id = "2e013e8-7623-4494-a347-6d29108ff68b"
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}
UI
다음은 기본 구성으로 새 SNI를 생성해요:
- 게이트웨이 인스턴스로 이동하세요:
- Konnect 사이드바에서 API Gateway > Gateways를 클릭한 다음 컨트롤 플레인을 선택하세요.
- Kong Manager에서 작업 영역을 선택하세요.
- 인증서로 이동하세요.
- SNI 탭을 선택하고 새 SNI를 클릭하세요.
- 이름 필드에 SNI 이름을 입력하세요:
example-sni - SSL 인증서 ID 필드에 기존 인증서의 ID를 선택하거나 입력하세요:
2e013e8-7623-4494-a347-6d29108ff68b - 저장을 클릭하세요.
스키마
{
"additionalProperties": false,
"description": "An SNI object represents a many-to-one mapping of hostnames to a certificate. That is, a certificate object can have many hostnames associated with it; when Kong receives an SSL request, it uses the SNI field in the Client Hello to lookup the certificate object based on the SNI associated with the certificate.",
"example": {
"certificate": {
"id": "bd380f99-659d-415e-b0e7-72ea05df3218"
},
"id": "36c4566c-14cc-4132-9011-4139fcbbe50a",
"name": "some.example.org"
},
"properties": {
"certificate": {
"description": "The id (a UUID) of the certificate with which to associate the SNI hostname. The Certificate must have a valid private key associated with it to be used by the SNI object.",
"properties": {
"id": {
"type": "string"
}
},
"type": "object",
"x-foreign": true
},
"created_at": {
"description": "Unix epoch when the resource was created.",
"nullable": true,
"type": "integer"
},
"id": {
"description": "A string representing a UUID (universally unique identifier).",
"nullable": true,
"type": "string"
},
"name": {
"description": "The SNI name to associate with the given certificate.",
"type": "string"
},
"tags": {
"description": "An optional set of strings associated with the SNIs for grouping and filtering.",
"items": {
"description": "A string representing a tag.",
"type": "string"
},
"nullable": true,
"type": "array"
},
"updated_at": {
"description": "Unix epoch when the resource was last updated.",
"nullable": true,
"type": "integer"
}
},
"required": [
"name",
"certificate"
],
"type": "object"
}
관련 리소스
더 알아보기 (Learn more)
- 인증서 엔티티에 대한 설명 — Certificate
- TLS 라우팅에서 SNI 사용 방법 — TLS Routes
- 라우팅 우선순위에 대한 자세한 내용 — Expressions Router
- SSL 인증서 사용에 대한 전반적인 가이드 — Using SSL certificates in Kong Gateway