EKS에서 HTTP를 HTTPS로 Redirect

EKS에서 HTTP를 HTTPS로 Redirect

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress
annotations:
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
alb.ingress.kubernetes.io/healthcheck-path: '/health'
alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:us-west-2:xxxx:certificate/xxxxxx
alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
spec:
rules:
- host: "www.sejoung.com"
http:
paths:
- pathType: ImplementationSpecific
path: /*
backend:
service:
name: ssl-redirect
port:
name: use-annotation
- pathType: ImplementationSpecific
path: /*
backend:
service:
name: "sejoung-develop"
port:
number: 8080

alb.ingress.kubernetes.io/listen-ports 설정에 [{"HTTP": 80}, {"HTTPS": 443}] 2개 포트를 열어야 됨

alb.ingress.kubernetes.io/certificate-arn 설정이 되어 있어야 됨

alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}' 설정이 되어 있어야 됨

최종적으로 제일 처음위치에 아래의 설정이 필요하다

1
2
3
4
5
6
7
- pathType: ImplementationSpecific
path: /*
backend:
service:
name: ssl-redirect
port:
name: use-annotation

참조