发布时间: 2024-1-16 文章作者: myluzh 分类名称: Kubernetes 朗读文章
# nginx节点 root@iZbp12bkuvg20e1j3y9gtvZ:/etc/nginx/conf.d# ifconfig | grep 172 inet 172.29.241.163 netmask 255.255.240.0 broadcast 172.29.255.255 # nginx反向代理到k8s-ingress的配置文件 root@iZbp12bkuvg20e1j3y9gtvZ:/etc/nginx/conf.d# cat prd-all.conf upstream prd-nginx-server { server 172.29.241.160:80; server 172.30.82.215:80; keepalive 10; keepalive_requests 100; } server { listen 80; server_name *.xxxxx.com; #root html; #index index.html index.htm; client_max_body_size 10m; location / { proxy_set_header Host $host; # 这里nginx已经配置了将客户端的真实IP地址传递给后端的服务器,证明没问题 proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://prd-nginx-server/; } }排障思路为:
root@iZbp12bkuvg20e1j3y9gtxZ:~# kubectl get configmap -n ingress-nginx NAME DATA AGE ingress-controller-leader 0 479d ingress-controller-leader-nginx 0 479d ingress-nginx-controller 0 479d kube-root-ca.crt 1 479d root@iZbp12bkuvg20e1j3y9gtxZ:~# kubectl edit configmap ingress-nginx-controller -n ingress-nginx apiVersion: v1 kind: ConfigMap data: use-forwarded-headers: "true" ...
标签: k8s nginx Ingress ip use-forwarded-headers X-Real-IP X-Forwarded-For
发表评论