ingress配置二级目录转发

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "false" # 确保不强制重定向到 HTTPS
    nginx.ingress.kubernetes.io/proxy-body-size: 100m
    nginx.ingress.kubernetes.io/rewrite-target: /$2   # 重写路径,这个代表的是被代理的172.16.0.239路径
    nginx.ingress.kubernetes.io/use-regex: "true"     #是否使用正则表达式,true表示使用
    nginx.ingress.kubernetes.io/enable-cors: "true"   # 启用跨域资源共享(CORS)
  name: sincerewatch
  namespace: dmp-prod
spec:
  ingressClassName: nginx
  rules:
  - host: idata.gmoregalax.com
    http:
      paths:
      - backend:
          service:
            name: sincerewatch
            port:
              number: 8001
        path: /sincerewatch(/|$)(.*)    #这里表示域名上需要重新的二级目录
        pathType: Prefix
  tls:
  - hosts:
    - idata.gmoregalax.com
    secretName: dmpssl-secret