简体   繁体   English

在负载均衡器后面配置Apache VirtualHosts

[英]Configure Apache VirtualHosts behind a Load Balancer

I have two servers, private IPs, Apache 2.4. 我有两个服务器,专用IP,Apache 2.4。 I am serving the same content in both servers and there is a load balancer in front of these servers. 我在两个服务器中都提供相同的内容,并且这些服务器前面有一个负载平衡器。

Load balancer uses a public IP, and there is a domain (mycompany.com) associated with it. 负载平衡器使用公共IP,并且有一个与其关联的域(mycompany.com)。

However, the client bought a new domain and want to use the same servers to serve the new content. 但是,客户端购买了一个新域,并希望使用相同的服务器来提供新内容。

As far as I understand I need to configure VirtualHosts. 据我了解,我需要配置VirtualHosts。 I've read the documentation regarding VirtualHosts and it seems to be a case for name-based virtual hosts. 我已经阅读了有关VirtualHosts的文档,对于基于名称的虚拟主机来说似乎是一种情况。

But since the public IP for the hostname is associated with the balancer, I do not know how I should configure the private servers in order that they be able to know how to solve which content to serve. 但是由于主机名的公共IP与平衡器相关联,所以我不知道如何配置私有服务器,以便它们能够知道如何解决要提供的内容。

Appreciate the guidance. 赞赏指导。

Solved using this answer: 使用以下答案解决:

Apache does not need to resolve anything regarding DNS. Apache不需要解决任何有关DNS的问题。

Just make sure each new virtualhost for the new domains have the appropiate "ServerName" entry reflecting that new domain, this way Apache HTTPD will know where to deliver the request with specified Host. 只需确保用于新域的每个新虚拟主机都具有反映该新域的适当“ ServerName”条目即可,这样Apache HTTPD将知道将请求与指定主机传递到何处。

Link: https://serverfault.com/a/835998/195783 链接: https//serverfault.com/a/835998/195783

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

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