Bug 37201 - Add <IfInterface IP> syntax to apache configuration
Summary: Add <IfInterface IP> syntax to apache configuration
Status: RESOLVED LATER
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.0.55
Hardware: Other other
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: MassUpdate
Depends on:
Blocks:
 
Reported: 2005-10-21 21:14 UTC by Glenn Nielsen
Modified: 2018-11-07 21:09 UTC (History)
1 user (show)



Attachments
server/core.c patch (2.96 KB, patch)
2005-10-21 21:15 UTC, Glenn Nielsen
Details | Diff
Second version of patch, now has IPV6 support. (2.94 KB, patch)
2005-10-21 23:37 UTC, Glenn Nielsen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Glenn Nielsen 2005-10-21 21:14:14 UTC
This patch adds the <IfInterface IP> configuration syntax.
It works similar to the <IfModule ..> syntax except that it
includes the nested configuration commands if the IP address
is configured on the interface for the server.

This makes mass virtual hosting with automatic failover using
technology like spread/wackamole easier.

Here is an example:

<IfInterface 204.185.42.129>
  Listen 204.185.42.129:80
  NameVirtualHost 204.185.42.129:80
  Include /export/kinetic/conf/apache/204.185.42.129/*.conf
</IfInterface>
Comment 1 Glenn Nielsen 2005-10-21 21:15:05 UTC
Created attachment 16773 [details]
server/core.c patch
Comment 2 Colm MacCarthaigh 2005-10-21 21:52:58 UTC
Kinda cool, can you describe the use-case a bit more? Is this for when an IP address is added to a 
system and you want httpd to behave differently after a restart? 

From a brief inspecion: Hard-coding APR_INET means that this patch will not work with IPv6, at all. You 
need to do the info_get first, with APR_UNSPEC as the family argument. Then create the socket using 
the sa->family variable. 

The EADDRINUSE error condition for bind() might need to be handled, for restarts - though I havn't 
tested this.

The syntax and log messages are majorly confusing, because "arg" is not a network interface; it's an IP 
address. 
Comment 3 Glenn Nielsen 2005-10-21 22:26:46 UTC
> Kinda cool, can you describe the use-case a bit more? Is this for when an IP
> address is added to a  system and you want httpd to behave differently after
> a restart?

Thanks. Here is the use case in more depth.

Say you have 500 virtual host's. A mix of IP based for SSL and name based for
non SSL. You have three servers in a cluster to host these 500 virtual hosts.
You place each virtual host config in a directory named by the IP address used
for the virtual host. These directories are located on an NFS server which is 
shared with each of the three servers. All three servers can see the config
files for all virtual hosts by IP address. But when apache starts on each
server it will only configure those virtual hosts for which the IP address
is configured on its interface.

The hosts in the cluster use spread and wackamole to provide automatic failover.
If server 1 goes down the IP's for virtual hosted websites currently on server 1
get split up between server 2 and 3. Then just doing an apachectl graceful will
instantiate those new virtual hosts on the other two servers.

Apache is also using mod_log_spread and spreadlogd for setting up a log server.

> From a brief inspecion: Hard-coding APR_INET means that this patch will not
> work with IPv6, at all. You  need to do the info_get first, with APR_UNSPEC
> as the family argument. Then create the socket using the sa->family variable.

Thanks, I was wondering how to best provide IPV6 support.

> The EADDRINUSE error condition for bind() might need to be handled, for
> restarts - though I havn't  tested this.

I have tested doing an apachectl graceful and <IfInterface ...> seems to
work fine. This has only been tested on FreeBSD 5.3.

> The syntax and log messages are majorly confusing, because "arg" is not
a network interface; it's an IP address.

Yes, the log messages could be cleaned up.

Perhaps <IfBind ...> rather than <IfInterface ...> ?


Comment 4 Glenn Nielsen 2005-10-21 23:37:49 UTC
Created attachment 16776 [details]
Second version of patch, now has IPV6 support.

Second version of patch, now has both IPV4 and IPV6 support.
Renamed to <IfBind ...>, cleaned up log messages.
Comment 5 Philp M. Gollucci 2009-01-18 16:19:22 UTC
CC myself on FreeBSD related bugs
Comment 6 William A. Rowe Jr. 2018-11-07 21:09:49 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd.

As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd.

If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question.

If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with.

Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.