基于请求主机头的mod_proxy Fowarding

比方说,我有3个url,他们都指向相同的反向代理。 我希望根据主机头将请求转发到代理后面的Web服务器:

webfront1.example.com > reverseproxy.example.com > backend1.example.com webfront2.example.com > reverseproxy.example.com > backend2.example.com webfront3.example.com > reverseproxy.example.com > backend3.example.com 

根据我读到的内容,我可以configurationreverseproxy.example.com/webfront1 > backend1.example.com, reverseproxy.example.com/webfront2 > backend2.example.com等。

我想知道如果代理基于主机头甚至可能或者如果我完全用错误的方法。

您可以使用基于名称的虚拟主机。 configuration示例:

 NameVirtualHost *:80 ProxyRequests off <VirtualHost *:80> ServerName webfront1.example.com ProxyPass / http://backend1.example.com/ ProxyPassReverse / http://backend1.example.com/ </VirtualHost> <VirtualHost *:80> ServerName webfront2.example.com ProxyPass / http://backend2.example.com/ ProxyPassReverse / http://backend2.example.com/ </VirtualHost> 

请注意,如果您想在reverseproxy.example.com上使用SSL,事情会变得更加复杂。