首页 > 代码库 > nginx 获取前端真实ip

nginx 获取前端真实ip

http {

#指定接收来自哪个前端发送的 IP head 可以是单个IP或者IP段
set_real_ip_from 10.168.38.0/24;
set_real_ip_from 10.132.44.0/24;
#此指令设置了IP地址头转发替换使用
real_ip_header X-Forwarded-For;

location ^~ /wdzjnews/ {
  proxy_pass http://wdzjnews;
  proxy_set_header Host $host:$server_port;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header REMOTE-HOST $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

 

nginx 获取前端真实ip