侧边栏壁纸
博主头像
张种恩的技术小栈博主等级

行动起来,活在当下

  • 累计撰写 748 篇文章
  • 累计创建 65 个标签
  • 累计收到 39 条评论

目 录CONTENT

文章目录

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

zze
zze
2020-12-08 / 0 评论 / 0 点赞 / 1322 阅读 / 987 字

方法一,在对应 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 所有可配置的字段可参考:

0

评论区