将同一个networking中的另一台服务器的Apache请求重写为VirtualHost

这里基本上是我想要做的:

  • http请求进来后,路由器中的前端将其发送到本地networking(服务器A)中的服务器,
  • 服务器识别虚拟主机的请求
  • 服务器a具有该虚拟主机的重写规则,该规则重写请求以将其发送到位于同一本地networking上的服务器B
  • 服务器B获取请求,识别虚拟主机并根据虚拟主机设置设置文档根目录

它一直运行到服务器B,请求总是以默认定义结束。 这可能吗? 我正在运行Debian Wheezy。

服务器apacheconfiguration文件/etc/apache/sites-enabled/wiki

 <Directory /var/lib/shared/websites/wiki/www> Options None AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName wiki ServerAlias wiki.asus.local ServerAlias wiki.mydomain.net DocumentRoot /var/lib/shared/websites/wiki/www CustomLog /var/lib/shared/websites/wiki/log/access.log combined ErrorLog /var/lib/shared/websites/wiki/log/error.log RewriteEngine on RewriteRule ^/(.*) http://192.168.10.91/$1 [P,L] </VirtualHost> 

服务器B apacheconfiguration文件/etc/apache/sites-enabled/wiki

 <Directory /var/lib/shared/websites/wiki/www> Options None AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerName wiki ServerAlias wiki.mydomain.net DocumentRoot /var/lib/shared/websites/wiki/www CustomLog /var/lib/shared/websites/wiki/log/access.log combined ErrorLog /var/lib/shared/websites/wiki/log/error.log </VirtualHost> 

哦,也是服务器B抱怨apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName重新启动Apache的apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ,这可能与此有关,但通常的答案就是添加ServerName localhost在这种情况下, apache.conf不可能是正确的,我所有的其他服务器都缺lessapache.conf的定义,也没有人抱怨过。

任何人有任何想法呢? 这甚至可能,我想要做什么? (重写虚拟主机,然后再将请求放入虚拟主机)

谢谢你的帮助!

我认为你的问题是RewriteRule ^/(.*) http://192.168.10.91/$1 [P,L] 。 如果你使用IP访问你的第二台服务器,虚拟主机不能工作。 您可以尝试为您的服务器B设置特定的域名,并在重写过程中将其replace为ip