繁体   English   中英

Apache反向代理配置始终返回同一站点

[英]Apache reverse proxy config always returning same site

情况:在专用虚拟机上安装了apache和bugzilla的ubuntu服务器14.04。 在bugzilla.myexternal.com,bugzilla.myinternal.xyz和LAN IP地址上,一切正常

现在,我想通过具有相同apache实例的基于主机名的转发,使其他内部服务器在同一外部IP上可用。 DNS记录已添加,并且可以正确解析other1.myexternal.com,other2.myexternal.com等

(内部DNS已将otherX的内部名称覆盖/解析为本地ip地址以供内部使用)

在阅读了这里和Apache上的散文后,我细细了解了我能够提取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>

other1 :(与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”时,我看到它们已正确加载。 但是在所有情况下(禁用某些虚拟主机时),显示的站点始终是'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

问题:如何使这项工作有效,并且不总是显示默认服务器?

我找到了原因,我很尴尬地说,但这取决于为其他serverName指定错误的域和TLD。 我们有几个doamin名称,只有我混在一起的不同TLD。 但是,由于我们使用CNAME记录设置了DNS,因此确实可以解决。

结果,apache找不到匹配的serverName,并且显示了默认名称。

好消息是(对于其他用户)上述配置有效,因此,如果在此unubtu和apache 2.4上需要反向代理和本地服务器组合,则这是前进的道路。

问候,克里斯托夫

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM