I have a server with several static IPs (127.0.0.1, 127.0.0.2, etc.). I'd like to make Apache only listen on the 127.0.0.1 IP address for every domain (virtualhosts).
I tried the following:
# No NameVirtualHost used
Listen 127.0.0.1:80
<VirtualHost one.domain.com>
...
</VirtualHost>
<VirtualHost two.domain.com>
...
</VirtualHost>
This didn't work as wanted as every virtualhost entry (and the IP) were pointing to the first VirtualHost entry.
Now I am using:
NameVirtualHost 127.0.0.1:80
Listen 80
<VirtualHost one.domain.com>
...
</VirtualHost>
<VirtualHost two.domain.com>
...
</VirtualHost>
But now Apache listens on every IP from the server.
Your first setup was correct in concept, wrong in implementation.