2015-04-01 84 views
0

情况:Ubuntu的服务器14.04与apache和bugzilla安装在专用虚拟机上。 一切运作良好,在bugzilla.myexternal.com,bugzilla.myinternal.xyz和局域网IP地址Apache反向代理配置总是返回相同的站点

现在我想要在同一个外部IP提供的其他内部服务器,基于主机名的转发,用相同的apache实例。 DNS记录添加和other1.myexternal.com,other2.myexternal.com正确解析等

(内部DNS已经涵盖/解析为供内部使用本地IP地址otherX的内部名称)

通过阅读后在这里和在apache的atricles,我瘦了,我能够蒸馏bugzila site-conf并按照预期添加其他site-conf。但是,有太多矛盾的文章和不同的“解决方案”,最终我无法实现。无论主机是什么,我总是以最初的bugzila网站结束。当我a2dissite bugzilla,然后我总是被转发到第一个反向代理站点(显示代理实际工作)

这是什么site-conf的样子。

的bugzilla:

<VirtualHost *:80> 
    ServerName bugzilla.myexternal.com 
    ServerAlias 192.168.aaa.bbb 

    DocumentRoot /var/www/html 
    <Directory /var/www/html> 
     AddHandler cgi-script .cgi 
     Options +ExecCGI 
     DirectoryIndex index.cgi index.html 
     AllowOverride Limit FileInfo Indexes Options 
    </Directory> 

</VirtualHost> 

其他1:(和otherX,所有具有静态内部IP类似)

<VirtualHost *:80> 
    ProxyPreserveHost On 
    ServerName other1.myexternal.com 

# ProxyRequests off ->also tried without commenting out 
    ProxyPass/http://192.168.aaa.ccc/ 
    ProxyPassReverse/http://192.168.aaa.ccc/ 
</VirtualHost> 

apache的重载没有错误/警告。

使用'apache2ctl -S'查看时,我发现它们加载正确。但是,在所有情况下(禁用某些虚拟主机的时候),这被显示的网站总是mentionned的默认服务器“apache2ctl -S”:

VirtualHost configuration: 
*:80     is a NameVirtualHost 
    default server bugzilla.myexternal.com (/etc/apache2/sites-enabled/bugzilla2.conf:1) 
    port 80 namevhost bugzilla.myexternal.com (/etc/apache2/sites-enabled/bugzilla2.conf:1) 
      alias 192.168.aaa.bbb 
    port 80 namevhost other1.myexternal.com (/etc/apache2/sites- enabled/comfoway.conf:2) 
    port 80 namevhost other2.myexternal.com (/etc/apache2/sites- enabled/spcway.conf:1) 
ServerRoot: "/etc/apache2" 
Main DocumentRoot: "/var/www" 
Main ErrorLog: "/var/log/apache2/error.log" 
Mutex proxy: using_defaults 
Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
Mutex watchdog-callback: using_defaults 
Mutex proxy-balancer-shm: using_defaults 
Mutex rewrite-map: using_defaults 
PidFile: "/var/run/apache2/apache2.pid" 
Define: DUMP_VHOSTS 
Define: DUMP_RUN_CFG 
Define: MODPERL2 
Define: ENABLE_USR_LIB_CGI_BIN 
User: name="www-data" id=33 
Group: name="www-data" id=33 

问:怎样做才能使这项工作,而不是总是显示默认服务器?

回答

0

我找到了原因,而且我很尴尬地说,但是这只是为其他serverNames规定了错误的域名和顶级域名(TLD)。我们有几个doamin名称,只有不同的TLD,我混在一起。但是他们确实解决了这个问题,这是由于我们的DNS是如何设置CNAME记录的。

因此,apache找不到匹配的serverName,并显示默认值。

好消息是(对于其他用户)上述配置工作,所以如果你需要在这个unubtu和apache 2.4上使用反向代理和本地服务器组合,那么这是前进的方向。

关于, Christof