1. 1.在编译nginx的时候./configure的时候  加上参数添加了一个 --with-http_realip_module 的模块来获取真实ip  
  2. 2.  在varnish的配置文件里添加varnish配置文件里的sub vcl_recv 里面加入以下这段:     
  3.     remove req.http.X-real-ip;   
  4.     set req.http.X-real-ip = client.ip;   
  5.     set req.http.X-Forwarded-For = client.ip;   
  6. 3 在nginx里添加也就是在虚拟机主机的配置文件里,添加了:  
  7. location / {   
  8.   set_real_ip_from   192.168.1.151;   
  9.   real_ip_header     X-Real-ip;   
  10.   }   
  11.  
  12. set_real_ip_from 是定义获取的源,就是从哪里获取值  
  13. real_ip_header  是定义获取哪个值。  
  14.