官方文档:https://github.com/kubernetes/ingress-nginx/blob/master/docs/user-guide/nginx-configuration/annotations.md

工作中遇到的实际问题总结:

1.nginx的路径和后端的路径不同;
例:访问xxx.xxx/apppy/api/test/pic的时候跳转到后端 xxx:xxx:8080/api/test/pic

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
  name: gos-api
  namespace: gos
spec:
  rules:
    - host: api.baidu.com
      http:
        paths:
          - backend:
              serviceName: gos-api
              servicePort: 80
            path: /apppy(/|$)(.*)