0

I want to configure Apache2 (on Ubuntu 14.04) such that it starts on boot and listens on 127.0.0.1:80 and 192.150.0.1:80.

For this, I have the following lines in /etc/apache2/ports.conf:

Listen 127.0.0.1:80
Listen 192.168.150.1:80

and the VirtualHost directive's start tag:

<VirtualHost 127.0.0.1:80 192.168.150.1:80> 

Things worked fine after these edits and running sudo apache2ctl restart.

But the latter IP is not bound to an active interface on the server at startup, so Apache could not start at next boot.

I found it here:

When trying to bind to an IP and port not present on the host system, apache httpd will fail to start.

I want apache to not kill itself if failing to bind on the latter IP is all that has went wrong. Is there any solution using Apache Configuration Directives that:

  • starts Apache successfully at boot even if the second address is not bound to any interface.
  • requires me to only switch on the interface and restart apache to listen on both addresses.

?

I do not want to manually edit /etc/apache2/ports.conf every time after switching on the interface.

1
  • The real problem you need to solve here is sorting out why these IPs are not being configured correctly. Doing something like you suggest is treating the symptom, not the disease. – EEAA Jun 16 '15 at 0:40
0

This is pretty common in HA setups with multiple sites on multiple IPs. The IPs are shared between the devices in HA.

Short answer, you cannot. Apache will not start without all IPs present on the device.

Our answer was to write an apache restart into the failover process ensuring the apache service would be restarted when a failover occurred.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.