Forum Moderators: phranque

Message Too Old, No Replies

Apache Bind problems

Will 'Listen 80' but not to specific IPs

         

billuk

3:12 pm on Sep 29, 2007 (gmt 0)

10+ Year Member



Hello!

I am trying to bind my Apache2 to specific IP addresses. Currently in the apache conf I have:

Listen 80

and then in my virtual hosts config I have:

NameVirtualHost 80.xx.xx.15:80
NameVirtualHost 80.xx.xx.17:80

<VirtualHost 80.xx.xx.15:80>

When I change the Listen part to :


Listen 80.xx.xx.15:80
Listen 80.xx.xx.17:80

Shutdown the server, check that nothing is running on port 80, and restart I get the error message:

(98)Address already in use: make_sock: could not bind to address 80.xx.xx.15:80 no listening sockets

and Apache exits. I have no other Listen's elsewhere in the code (I do have a ServerName outside of the Virtualhost, if that makes a difference?). I change it back to Listen 80 and it works again no problem! I'm limited to experiment too much, as it's a live server.

What could be the problem? Please help!

encyclo

8:47 pm on Sep 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi billuk, I'm not sure I understand the problem precisely. Are you trying to use the
Listen
directive to limit the IP addresses to which Apache responds?

billuk

9:08 pm on Sep 30, 2007 (gmt 0)

10+ Year Member



Hi there. Yes, that's right, currently the server has 3 IP addresses and the 'Listen 80' means that Apache responds to all 3. I want to limit that, so that it will only respond to 2 IP addresses, the other 1 I want to use for Lighttpd.

encyclo

9:19 pm on Sep 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, makes sense. I think I can see what the problem might be: you are listing port 80 twice (once for each IP address), and so the second one throws the error:

[httpd.apache.org...]

Error condition
Multiple Listen directives for the same ip address and port will result in an Address already in use error message.

However in the documentation there is at least one example using your syntax, and the above quote gives the impression that the error condition would be because both the IP address and port are the same.

I'm still trying to find a solution. :)

Which Apache version are you using, on which OS?

billuk

9:34 pm on Sep 30, 2007 (gmt 0)

10+ Year Member



I'm using Debian and
Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.8d Zend Core/2.0.0 PHP/5.2.1

billuk

9:38 pm on Sep 30, 2007 (gmt 0)

10+ Year Member



Do you think it could be how the multiple interfaces are defined. That Apache is seeing them as the same IP?

Here is my /etc/network/interfaces file:

auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 80.xx.xx.14
netmask 255.255.255.0
network 80.xx.xx.0
broadcast 80.xx.xx.255
gateway 80.xx.xx.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 80.xx.xx.20
dns-search xx.co.uk

iface lo:1 inet static
address 80.xx.xx.15
netmask 255.255.255.255

iface lo:2 inet static
address 80.xx.xx.16
netmask 255.255.255.255

iface lo:3 inet static
address 80.xx.xx.17
netmask 255.255.255.255