本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名原文链接~~~

配置Nginx Ingress Controller获取客户端真实IP

微信搜索 zze_coding 或扫描 👉 二维码关注我的微信公众号获取更多资源推送:


方法一,在对应 Ingress 添加注解:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: cafe-ingress-with-annotations
  annotations:
    nginx.org/compute-full-forwarded-for: "true"
    nginx.org/forwarded-for-header: "X-Forwarded-For"
    nginx.org/use-forwarded-headers: "true"
    ...

方法二,编辑 Ingress Controller 的公共 ConfigMap:

$ kubectl get cm -n ingress <cm_name> -o yaml
apiVersion: v1
data:
  compute-full-forwarded-for: "true"
  forwarded-for-header: "X-Forwarded-For"
  use-forwarded-headers: "true"
  ...
kind: ConfigMap
metadata:
  annotations:
  ...

Nginx Ingress Controller 所有可配置的字段可参考:

# Kubernetes  

如果这篇文章对您有帮助,可点击下方链接分享给你的朋友们😋,如果遇到问题欢迎评论、留言~~~😇

评论

公众号:zze_coding

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×