Score:1

Apache ProxyPass to Shared Ip Address for Domain

pl flag

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?

Score:2
cn flag

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>
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.