Apache – httpd.confredirect与X-Forward-For – 无法正常工作?

我遇到了redirectstream量的问题。 基本上,我正在构build一个新的Web服务器,它在我的域的另一个版本,所以我想redirectstream量不是从这个IP。

问题是亚马逊的ELB负载平衡器是在路上,所以它取代了REMOTE IP地址。 正常的获得方法。 研究发现我需要使用%{X-Forward-For}我 – 但它不工作,我不知道我是否已经在正确的位置和语法。 我正在运行虚拟主机,所以我把VirtualHost标签…

<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/vhosts/foo/www.bar.com/htdocs/ ServerName www.bar.com ErrorLog /var/www/vhosts/foo/www.bar.com/logs/error.log CustomLog /var/www/vhosts/foo/www.bar.com/logs/access.log common RewriteEngine On RewriteCond %{X-Forwarded-For}i !^xxx\.xxx\.xxx\.xxx RewriteRule ^.*$ http://www.bar.com/ [R,L] </VirtualHost> 

Obv xxx.xxx.xxx.xxx是我的IP。

这是错的吗?

在我头上:不应该这样

 RewriteCond %{X-Forwarded-For} !^xxx\.xxx\.xxx\.xxx 

 RewriteCond %{HTTP:X-Forwarded-For} !^xxx\.xxx\.xxx\.xxx 

要不就

 RewriteCond %{HTTP_FORWARDED} !^xxx\.xxx\.xxx\.xxx