I have multiple urls coming into a server. I want to user host headers to redirect the traffic. I am trying to use Apache to redirect these requests to various servers that are inside our firewall. I have gotten part of the solution, but, I seem to be missing something.

For example, http://hostHeader1.mycompany.com should be redirected to a server inside our firewall that handles requests for hostHeader1, and the result should be handed back to the client. http://hostHeader2.mycompany.com should be redirected to a server inside our firewall that handles requests for hostHeader2. Etc.

Right now, I have the following, but, it redirects all traffic to http://hostHeader1Handler/:

<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://hostHeader1Handler/
ProxyPassReverse / http://hostHeader1Handler/
ServerName hostHeader1.mycompany.com
</VirtualHost> 

Any help appreciated.

Scott

有帮助吗?

解决方案

This is probably your first or your only virtual host. Just add another virtual host before. Then this should be the new default.

NameVirtualHost *:*
<VirtualHost *:*>
    ServerName your.default.domain.de
DocumentRoot /var/www/pathToHTML
</VirtualHost>

<VirtualHost *:*>
    ProxyPreserveHost On
    ProxyPass / http://hostHeader1Handler/
    ProxyPassReverse / http://hostHeader1Handler/
    ServerName hostHeader1.mycompany.com
</VirtualHost> 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top