Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 ?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
Hi Heiko, thanks for your answer. The question is that I want to use DNS and IP. so when a client use tha IP I need to add the HOSTNAME but the host name is configured on the Proxy IP. –  Marco Nov 26 '10 at 20:13
    
You could add a VirtualHost before the existing VirtualHost with ServerName (MYPROXYIP). This VirtualHost-Config would be used only, if no Host Header is present in the Request (or if no other VirtualHost-Config exists for the Host-Header in the Request). –  heiko Nov 26 '10 at 21:07
    
"RequestHeader set Host www.somedomain.com" will set a Host Header to the Request –  heiko Nov 26 '10 at 21:09

Solved using

In /etc/hosts I add the real backend IP with the DNS configured on the PROXYIP X.X.X.X DNSTOREACH

<VirtualHost PROXYIP>
        ProxyRequests Off
        ProxyVia On
        ProxyTimeout 300
        <Proxy *>
        Allow from all
        </Proxy>
        ServerName DNSTOREACH

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

so, PROXYIP has an A record and on the proxy server is configured in /etc/hosts with the backend IP.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.