You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Cahya Wirawan <cw...@email.archlab.tuwien.ac.at> on 2003/11/11 13:00:22 UTC

How to bind apache to a specific ip address?

Hi,
following is my virtualhost configuration:

Listen 192.168.0.2:80
NameVirtualHost 192.168.0.2:80
<VirtualHost 192.168.0.2>
  ServerName        abc.mydomain.org
  ProxyPass         /  http://def.mydomain.org/
  ProxyPassReverse  /  http://def.mydomain.org/
</VirtualHost>

and the main ip address of my interface is 192.168.0.1 (eth0), and
192.168.0.2 is only an alias to the same interface (eth0:0), .
everything is fine, 192.168.0.2 listen to port 80, and the request to
this ip address with host header abc.mydomain.org will be proxied to
def.mydomain.org. The only problem is that def.mydomain.org get
http request from ip address 192.168.0.1 , and not from 192.168.0.2.
So, how can I tell apache to use 192.168.0.2 instead of 192.168.0.1
if it makes http request to def.mydomain.org ?

thanks for any help,
cahya.        


Re: How to bind apache to a specific ip address?

Posted by Jeff Trawick <tr...@attglobal.net>.
Cahya Wirawan wrote:

> Listen 192.168.0.2:80
> NameVirtualHost 192.168.0.2:80
> <VirtualHost 192.168.0.2>
>   ServerName        abc.mydomain.org
>   ProxyPass         /  http://def.mydomain.org/
>   ProxyPassReverse  /  http://def.mydomain.org/
> </VirtualHost>
> 
> and the main ip address of my interface is 192.168.0.1 (eth0), and
> 192.168.0.2 is only an alias to the same interface (eth0:0), .
> everything is fine, 192.168.0.2 listen to port 80, and the request to
> this ip address with host header abc.mydomain.org will be proxied to
> def.mydomain.org. The only problem is that def.mydomain.org get
> http request from ip address 192.168.0.1 , and not from 192.168.0.2.
> So, how can I tell apache to use 192.168.0.2 instead of 192.168.0.1
> if it makes http request to def.mydomain.org ?

this sounds like a question for the user list

no, AFAICT there is no way to get mod_proxy to bind the client side of the 
socket to a particular IP before it connects that socket to def.mydomain.org... 
  the interface the kernel uses to route the connection will be the client 
(source) IP that the server on def.mydomain.org will see... potentially you 
could hack mod_proxy do to a bind do some source IP address before connecting

maybe there are other tricks, but I don't know them