먼저 helm 을 이용하여 ingress-nginx 설치시 https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx 를 참고하며, controller.allowSnippetAnnotations: true 를 지정하여 설치하여야 한다.

그리고 Ingress 의 annotations 에 아래와 같이 configuration-snippet 를 설정해주면 된다.

...
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ($scheme = http) {
        return 301 https://$host:<리다이렉션 할 포트>$request_uri;
      }
...

이렇게 하면 http 요청시 https 와 지정한 포트로 리다이렉션 된다. 수신 서버에서는 해당 포트를 https 포트로 지정하고 tls 설정을 해두면 된다.

블로그 이미지

망원동똑똑이

프로그래밍 지식을 자유롭게 모아두는 곳입니다.

,