Add host with mod_proxy in Apache

apache-2.2mod-proxy

I have an Apache2 with Mod_Proxy to reach the backend (IIS with some websites, all configured with hostname on a single IP).

I want to add the host header to reach the domain using the IP of the proxy (not with hostname).

<VirtualHost MYPROXYIP>
        ProxyPreserveHost On
        ProxyRequests Off
        ProxyVia On
        ProxyTimeout 300
        <Proxy *>
        Allow from all
        </Proxy>
        ServerName www.mywebsite.com 

        ProxyPassReverse / http://MYBACKENDIP/
        ProxyPass / http://MYBACKENDIP/
</VirtualHost>

Now, MYBACKENDIP need a hostname.
how can I pass it ?

Best Answer

If you set ProxyPreserveHost On, this option will pass the Host: line from the incoming request to the proxied host, instead of the hostname specified in the ProxyPass line.

So, if you want the ServerName www.mywebsite.com to be forwarded to the Proxy, use "ProxyPreserveHost On". If you want to set another Hostname, delete this Directive and the Hostname in the ProxyPass Directive will be used.