我在 Kubernetes 上的命名空间有以下入口,路径如下/api/1.0/重定向到我的旧服务,其余重定向到新服务。在弃用和删除我的旧服务之前,我希望 Nginx 仅在以下情况下响应 HTTP 426 重定向错误代码:/api/1.0/路径。
我怎样才能做到这一点 ?
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: xxx-ingress
namespace: xxx-ingress
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/proxy-next-upstream: "error timeout http_502 non_idempotent"
nginx.ingress.kubernetes.io/proxy-pass-headers: "Content-Length"
spec:
ingressClassName: nginx
tls:
- hosts:
- api.xxx.com
- www.xxxcom
secretName: xxx-ingress-tls
rules:
- host: api.xxx.com
http:
paths:
- path: /api/1.0/users/password/reset/token
pathType: ImplementationSpecific
backend:
service:
name: old-service
port:
number: 80
- path: /api/1.0/users/login
pathType: ImplementationSpecific
backend:
service:
name: old-service
port:
number: 80
- path: /api/1.0/users/request_migration_sync
pathType: ImplementationSpecific
backend:
service:
name: old-service
port:
number: 80
- path: /api/1.0/users/migrate
pathType: ImplementationSpecific
backend:
service:
name: old-service
port:
number: 80
- path: /
pathType: ImplementationSpecific
backend:
service:
name: new-service
port:
number: 80
- host: www.xxx.com
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: new-service
port:
number: 80