1

I have a case where I need to proxy pass a domain (domain1.com) to a different domain (domain2.com) hosted on a shared ip address (192.168.168.168), but domain2.com DNS is pointed other than the shared ip address, so domain2.com cannot be used as the proxy pass, only the shared ip address.

Since the shared ip address has multiple hostnames, is there a domain or hostname configuration option that can be used with proxypass to force the virtual host lookup on the other side? For example, using this apache conf file to proxy domain1.com to 192.168.168.168.

#Apache Reverse Proxy
SSLProxyEngine on

<Location />
ProxyPass http://192.168.168.168/
ProxyPassReverse http://192.168.168.168/
</Location>

Are there any changes that can be made to tell what domain to lookup on that ip?

1 Answer 1

2

The webserver on the shared IP-address (192.168.168.168) relies on the Host header with a known host/domain-name to display the correct content.

You can normally achieve that easily by actually using that host/domain-name in the ProxyPass directive :

<Location />
    ProxyPass http://domain2.com/
    ProxyPassReverse http://domain2.com/
</Location>

Since you state that the actual DNS entry for domain2.com is incorrect you override that by adding domain2.com with the 192.168.168.168 IP-address in your web servers hosts file

# /etc/hosts 
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

# added for Apache reverse proxy 
192.168.168.168 domain2.com

The alternative is to configure Apache explicitly to set the correct Host header, with an RequestHeader Directive, something along the lines of:

<Location />
    RequestHeader set Host "domain2.com"
    ProxyPass http://192.168.168.168/
    ProxyPassReverse http://domain2.com/
</Location>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .