AWS's ALB does not support rule rewriting, so you need to use nginx ingress to bind AWS's NLB to achieve it.
Advantages of NLB:
All namespaces can share one NLB
1. Installation
Reference official website address: https://kubernetes.github.io/ingress-nginx/deploy/#aws
2. Notes
1) The entrance uninstalls SSL, which is used to convert HTTPS to HTTPS inside the service. For example, the Pod is a tomcat and uses the https protocol. To prevent nginx ingress from converting https to http at the entrance and entering tomcat, you can add the following comment:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
2) Path rewriting
For example, forward all requests from https://domain name/api/user/ids to https://domain name/user/ids, that is, rewrite the /api/user/ids path to /user/ids
Request prefix:/api(/|$)(.*)
Note:nginx.ingress.kubernetes.io/rewrite-target:$2
3) Turn on the external network type lb