安装mod_rpaf

wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar xvfz mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

/usr/local/apache/modules目录多出mod_rpaf-2.0.so

编辑/usr/local/apache/conf/httpd.conf

添加LoadModule rpaf_module        modules/mod_rpaf-2.0.so

添加在最后就ok RPAFenable On
             RPAFsethostname On
              RPAFproxy_ips 192.168.2.209 #ip换成前端nginx服务器ip
              RPAFheader X-Forwarded-For 

然后nginx是做代理的,修改nginx的配置文件,编辑/usr/local/nginx/conf/nginx.conf

nginx做代理和均衡负载。

upstream wangzai{

        server 192.168.2.209:8080;

        ip_hash;

        }

    server {

        listen       80;

        server_name  www.wangzai.com;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        location / {

            root   html;

            index  index.html index.htm;

            proxy_pass http://wangzai;

            proxy_set_header Host $Host;

            proxy_set_header X-real-ip $remote_addr;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            client_max_body_size 10m;

        }

   }

然后重启apache和nginx,/etc/init.d/httpd restart;/etc/init.d/nginx restart.