apache proxypassreverse ServerName不起作用

我有一个二次开发WordPress的网站。 (Centos 6.6 x86,LAMP)由于网站的规模越来越大。 (300GB +)。 现在我把它分成3个服务器。

域名:www.example.com

server1 46.192.22.01 /var/www/public_html /music /video server2 46.192.22.02 /var/www/public_html /article /photo server3 172.192.22.03 /var/www/public_html /products /showroom 

3 ips已经在域DNS中设置。 我想让他们成为一个集群。 自定义访问我的网站由不同的URL,Apache将select正确的服务器,其中陆地页面文件。

 www.example.com/music/xxx mapping to server with 172.192.22.01 www.example.com/article/xxx mapping to server with 172.192.22.02 www.example.com/products/xxx mapping to server with 172.192.22.03 

现在我用了apache proxypassreverse。

/etc/httpd/conf/httpd.conf在server1中

 ServerName www.example.com:80 <VirtualHost *:80> ServerName www.example.com ServerAlias www.example.com DocumentRoot /var/www/html <directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from all </directory> <Proxy *> Order deny,allow Allow from all </Proxy> ProxyRequests Off ProxyPass /article http://46.192.22.02/article ProxyPassReverse /article http://46.192.22.02/article ProxyPass /photo http://46.192.22.02/photo ProxyPassReverse /photo http://46.192.22.02/photo ProxyPass /products http://46.192.22.03/products ProxyPassReverse /products http://46.192.22.03/products ProxyPass /showroom http://46.192.22.03/showroom ProxyPassReverse /showroom http://46.192.22.03/showroom </VirtualHost> 

/etc/httpd/conf/httpd.conf在server2中

 ServerName www.example.com:80 <VirtualHost *:80> ServerName www.example.com ServerAlias www.example.com DocumentRoot /var/www/html <directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from all </directory> <Proxy *> Order deny,allow Allow from all </Proxy> ProxyRequests Off ProxyPass /music http://46.192.22.01/music ProxyPassReverse /music http://46.192.22.01/music ProxyPass /video http://46.192.22.01/video ProxyPassReverse /video http://46.192.22.01/video ProxyPass /products http://46.192.22.03/products ProxyPassReverse /products http://46.192.22.03/products ProxyPass /showroom http://46.192.22.03/showroom ProxyPassReverse /showroom http://46.192.22.03/showroom </VirtualHost> 

/etc/httpd/conf/httpd.conf在server3中

 ServerName www.example.com:80 <VirtualHost *:80> ServerName www.example.com ServerAlias www.example.com DocumentRoot /var/www/html <directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride all Order Deny,Allow Deny from all Allow from all </directory> <Proxy *> Order deny,allow Allow from all </Proxy> ProxyRequests Off ProxyPass /music http://46.192.22.01/music ProxyPassReverse /music http://46.192.22.01/music ProxyPass /video http://46.192.22.01/video ProxyPassReverse /video http://46.192.22.01/video ProxyPass /article http://46.192.22.02/article ProxyPassReverse /article http://46.192.22.02/article ProxyPass /photo http://46.192.22.02/photo ProxyPassReverse /photo http://46.192.22.02/photo </VirtualHost> 

现在我可以打开我的网站与每个文件夹www.example.com/music/xxx www.example.com/music/article,www.example.com/music/products,

但是, echo $_SERVER["SERVER_NAME"]echo $_SERVER['HTTP_HOST']全部返回IP地址。 httpd.conf中的ServerName似乎不起作用。 我在哪里设置错了?

看来proxy balancer snippet丢失了。 根据这个文件 ,平衡器设置看起来如下:

 ProxyPass /special-area http://special.example.com smax=5 max=10 ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On <Proxy balancer://mycluster> BalancerMember ajp://1.2.3.4:8009 BalancerMember ajp://1.2.3.5:8009 loadfactor=20 # Less powerful server, don't send as many requests there, BalancerMember ajp://1.2.3.6:8009 loadfactor=5 </Proxy>