背景

业务架构:client --> nginx --> ingress nginx controller --> svc --> pod

nginx中获取真实IP的配置

参考链接:https://developer.aliyun.com/article/70565

容器中获取真实IP的配置

修改容器ingress-nginx-controller的configmap
data下增加3行内容

compute-full-forwarded-for: "true"
forwarded-for-header: "X-Forwarded-For"
use-forwarded-headers: "true"

更多参数参考链接:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/?spm=a2c6h.12873639.article-detail.6.122b7e88zXShVy#compute-full-forwarded-for

posted on 2023-05-24 14:43  jiayou111  阅读(556)  评论(0编辑  收藏  举报