Infra/IaC
[k8s] Nginx Ingress : Rewrite Target
jykim23
2023. 11. 16. 18:04
728x90
너무 감사한 블로그
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
728x90