Forum Moderators: phranque

Message Too Old, No Replies

apache + two interfaces

         

japhar

10:44 pm on Jan 31, 2007 (gmt 0)

10+ Year Member



Hey,

I have server which has w interfaces (2 different ip's)

In configuration file i have:
Listen xx.xx.xx.xx:80
Listen yy.yy.yyy.yy:80
so apache listen on both interfaces.

Problem is that outgoing traffic from server is served thru one interface (xx.xx.xx.xx).

How can i force apache to serve outgoing traffic thru right interface depends on requested domain?

Example:
If someone request example.com (which is pointed to xx.xx.xx.xx) outgoing traffic goes thru interface1 (eth0)

But if someone request elpmaxe.moc (which is pointed to yy.yy.yyy.yy) outgoing traffic goes thru interface2 (eth1)

Any help will be appriciated.

Regards, japhar

jdMorgan

2:17 pm on Feb 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you trying to implement IP-based virtual hosts [httpd.apache.org], or Name-based virtual hosts [httpd.apache.org] using multiple NICs?

Either way, I think you'll want to define the IP address at the VirtualHost level, and not using "Listen".

Jim

japhar

5:27 pm on Feb 2, 2007 (gmt 0)

10+ Year Member



Hey jd,

This is how i have configured my virtual hosting using Apache 2.2.4.

/usr/local/apache2/conf/httpd.conf
Listen xx.xx.xx.xx:80
Listen yy.yy.yy.yy:80
According to online documentation Listen directive is required.
NameVirtualHost xx.xx.xx.xx
NameVirtualHost yy.yy.yy.yy

Then i start configuring my virtual host:
<VirtualHost xx.xx.xx.xx>
...
</VirtualHost>

<VirtualHost yy.yy.yy.y>
...
</VirtualHost>

etc etc.

All works fine, but the problem is that outgoing traffic goes thru first NIC which has ip: xx.xx.xx.xx

Here's some ifconfig results:
eth0 (xx.xx.xx.xx)
RX bytes:2893274010 (2.6 GiB) TX bytes:2060233362 (1.9 GiB)
eth1 (yy.yy.yy.yy)
RX bytes:1876431674 (1.7 GiB) TX bytes:7496 (7.3 KiB)

As you cen see all goes thru eth0. Am i missing something in my configuration?

Thanks in advace, japhar

jdMorgan

6:15 pm on Feb 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Are you trying to implement IP-based virtual hosts, or Name-based virtual hosts using multiple NICs?

Your config basically looks OK, but without an answer to the above question, all I can do is to refer you to the last major paragraph here [httpd.apache.org]. Where you go from there depends on whether you intend to set up more than one server per IP address.

Jim

japhar

12:11 pm on Feb 7, 2007 (gmt 0)

10+ Year Member



> Are you trying to implement IP-based virtual hosts, or Name-based virtual hosts using multiple NICs?

I'm trying to implement name-based virtual hosts. Cant afford to have different IPs for every vhost. Basicly i moved 2 servers to one machine which have 2 NICs and i want to keep the kinda separate if u know what i mean.

japhar

3:29 pm on Feb 11, 2007 (gmt 0)

10+ Year Member



Any more tips where i should start looking?
Maybe this is not an apache issue at all?

jdMorgan

6:29 pm on Feb 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All I can recommend without being there to see exactly what you are doing is to install two instances of Apache on the machine and bind each one to one of your two NICs. Or keep it simple and just use one NIC.

Jim