Infra/IaC

[k8s] Nginx Ingress : Rewrite Target

jykim23 2023. 11. 16. 18:04

너무 감사한 블로그

https://thekoguryo.github.io/oracle-cloudnative/oss/ingress-controller/2.nginx-ingress-path/

 

공식 문서: https://kubernetes.github.io/ingress-nginx/examples/rewrite/

 

URL예시 : localhost/project

파드까지 통신확인 했으나 'http://localhost/project/index.html'을 벗어나질 못했다.

rewrite로 'project' 후의 파라미터도 던져줘야한다.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: web-ingress
  #namespace: web
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /(/|$)(.*)
        pathType: ImplementationSpecific
        backend:
          service:
            name: svc-nginx
            port:
              number: 80
      - path: /project(/|$)(.*)
        pathType: ImplementationSpecific
        backend:
          service:
            name: svc-pdf
            port:
              number: 80

'Infra > IaC' 카테고리의 다른 글

[k8s] kubeflow install : 진행중  (0) 2023.11.19
[k8s] NFS Provider - Persistent Volumes 구성  (0) 2023.11.19
[k8s] nginx forward proxy (정방향 프록시)  (0) 2023.11.09
[IaC] k9s 설치  (0) 2023.11.08
[k8s] Ubuntu 22.04 설치 정리 231029  (1) 2023.10.29