K8S POD如何获取客户端IP

  • 问题:
    在K8S上部署应用时候,会发现从POD里边获取的IP一直都是F5的IP,思虑良久,怀疑是Ingres端那边被丢弃了类似X-FORWARD-FOR的信息,于是就有了下面的解决方案。
  • 解决方案:
    Rancher上配置界面如下,在项目:System,命名空间ingress-nginx,配置映射: nginx-configuration中增加键值对即可。
    • 参数说明:
      (1)compute-full-forwarded-for
      Append the remote address to the X-Forwarded-For header instead of replacing it. When this option is enabled, the upstream application is responsible for extracting the client IP based on its own list of trusted proxies.
      (2)forwarded-for-header
      Sets the header field for identifying the originating IP address of a client. default: X-Forwarded-For
      (3)use-forwarded-headers
  • If true, NGINX passes the incoming X-Forwarded-* hea

你可能感兴趣的:(k8s技术分享,k8s,ingress,云原生)