You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Benjamin <be...@netyantra.com> on 2005/03/10 10:51:46 UTC

[users@httpd] conditonal listen???

Hello ppl,

I intend to run apache httpd, on a server, which creates an alias(when 
it is up),  on the default port 80.
When the server is down, I still want httpd to run but on a different 
port. I can do that, again with the port/Listen directive.

My problem is the IP.
When the server is UP, I want apache to listen on the alias that i created.
But if the alias duznt exist, I want it to listen on INADDR_ANY.

I tried putting in both the IPs, viz, the alias and INADDR_ANY(in fact, 
also tried an actual IP on the machine) in two Listen directives.
If the alias exists, apache duz start the httpd.
But if it duznt, it simply exits, giving a bind error:
Cannot assign requested address: make_sock: could not bind to address 
<alias IP>.

Is there any way to tell apache to check the existence of the IP, if not 
do something else.

Any ideas anyone?

-- 

Benjamin Jacob.

Disclaimer :
------------------------------------------------------------------------------
If you are not the intended recipient of this transmission to whom it is
addressed, or have received this transmission in error, you are hereby
notified that any dissemination, distribution or copying of this transmission
is strictly prohibited. Please notify us immediately and delete this e-mail
from your system. The sender does not accept liability for any errors or
omissions in the contents of this message which arise as a result of e-mail
transmission, which cannot be guaranteed to be secure or error-free as
information could be intercepted, corrupted, lost, destroyed, arrive late or
incomplete, arrive at wrong address or contain viruses. If verification
is required please request a hard-copy version.  This e-mail contains only the
personal opinions of the sender and does not represent an official
communication from NetYantra of any manner.
------------------------------------------------------------------------------



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] conditonal listen???

Posted by Benjamin <be...@netyantra.com>.
Hey Joshua,
Thanx a ton.
It duz work, with that IfDefine test.

But I came across this problem, with Apache 2.
I could find no option to specify the User name and Group thru 
configure, which was existent in Apache 1.3

Now, if i dont specify anything other than the PREFIX, I see a "nobody" 
against the user and some strange value against the Group in httpd.conf.

Tried to look around, but couldnt find any help.

Thanx again.

Joshua Slive wrote:

>On Thu, 10 Mar 2005 15:21:46 +0530, Benjamin <be...@netyantra.com> wrote:
>  
>
>>Is there any way to tell apache to check the existence of the IP, if not
>>do something else.
>>    
>>
>
>Not that I know of.  I would simply write a simple script that checked
>if the IP was available and started apache with, for example
>"apachectl -D IPAvailable".  Then you can include in your config an
><IfDefine IPAvailable> section that will only be used in that case.
>
>Joshua.
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>  
>

-- 

Benjamin Jacob.

Disclaimer :
------------------------------------------------------------------------------
If you are not the intended recipient of this transmission to whom it is
addressed, or have received this transmission in error, you are hereby
notified that any dissemination, distribution or copying of this transmission
is strictly prohibited. Please notify us immediately and delete this e-mail
from your system. The sender does not accept liability for any errors or
omissions in the contents of this message which arise as a result of e-mail
transmission, which cannot be guaranteed to be secure or error-free as
information could be intercepted, corrupted, lost, destroyed, arrive late or
incomplete, arrive at wrong address or contain viruses. If verification
is required please request a hard-copy version.  This e-mail contains only the
personal opinions of the sender and does not represent an official
communication from NetYantra of any manner.
------------------------------------------------------------------------------


Re: [users@httpd] conditional listen???

Posted by Benjamin <be...@netyantra.com>.
oopps !!!
i sure was confused.

but somehow.. it did seem to work.. i wonder how.
If i specify the path of the script both in httpd.conf and with the -D 
option.. it did work.

Neway.. thanx again for the help.


Joshua Slive wrote:

>On Tue, 15 Mar 2005 14:59:38 +0530, Benjamin <be...@netyantra.com> wrote:
>  
>
>> Wot is the default directory into which this IfDefine directive will look
>>for the said script.
>> 
>> I tried all combinations under /home/user/apache/ , /home/user/apache/conf,
>>/home/user/apache/bin/ or the directory from where I call httpd.
>> the directive inside httpd.conf looks somethign like this:
>> <IfDefine IPAvailable> Listen 12.34.56.89:80 </IfDefine> Unless i specify
>>the complete path in the IfDefine like : <IfDefine
>>/home/user/apache/IPavailable> Listen 12.34.56.89:80 </IfDefine> and also
>>along with the -D option for httpd ie. httpd -D
>>/home/user/apache/IPavailable it duz not seem to work. Shud the script be
>>under the ServerRoot , which is /home/user/apache/ for me. 
>>    
>>
>
>I think you are a little confused.
>
>You need to write a script that checks to see whether the IP address
>is available.  Then at the end of this script, you start apache as
>follows (using pseudo-code):
>
>if the IP address is available
>  apachectl -D IPavailable
>else
>  apachectl
>end
>
>The <IfDefine IPavailable> block does not run a script.  It simply
>checks to see whether a particular variable (IPavailable) was passed
>on the command line when apache was started.  It is your
>responsibility to pass that variable conditional on the availability
>of the IP address.
>
>Joshua.
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>  
>

-- 

Benjamin Jacob.

Disclaimer :
------------------------------------------------------------------------------
If you are not the intended recipient of this transmission to whom it is
addressed, or have received this transmission in error, you are hereby
notified that any dissemination, distribution or copying of this transmission
is strictly prohibited. Please notify us immediately and delete this e-mail
from your system. The sender does not accept liability for any errors or
omissions in the contents of this message which arise as a result of e-mail
transmission, which cannot be guaranteed to be secure or error-free as
information could be intercepted, corrupted, lost, destroyed, arrive late or
incomplete, arrive at wrong address or contain viruses. If verification
is required please request a hard-copy version.  This e-mail contains only the
personal opinions of the sender and does not represent an official
communication from NetYantra of any manner.
------------------------------------------------------------------------------


Re: [users@httpd] conditional listen???

Posted by Joshua Slive <js...@gmail.com>.
On Tue, 15 Mar 2005 14:59:38 +0530, Benjamin <be...@netyantra.com> wrote:
>  Wot is the default directory into which this IfDefine directive will look
> for the said script.
>  
>  I tried all combinations under /home/user/apache/ , /home/user/apache/conf,
> /home/user/apache/bin/ or the directory from where I call httpd.
>  the directive inside httpd.conf looks somethign like this:
>  <IfDefine IPAvailable> Listen 12.34.56.89:80 </IfDefine> Unless i specify
> the complete path in the IfDefine like : <IfDefine
> /home/user/apache/IPavailable> Listen 12.34.56.89:80 </IfDefine> and also
> along with the -D option for httpd ie. httpd -D
> /home/user/apache/IPavailable it duz not seem to work. Shud the script be
> under the ServerRoot , which is /home/user/apache/ for me. 

I think you are a little confused.

You need to write a script that checks to see whether the IP address
is available.  Then at the end of this script, you start apache as
follows (using pseudo-code):

if the IP address is available
  apachectl -D IPavailable
else
  apachectl
end

The <IfDefine IPavailable> block does not run a script.  It simply
checks to see whether a particular variable (IPavailable) was passed
on the command line when apache was started.  It is your
responsibility to pass that variable conditional on the availability
of the IP address.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] conditional listen???

Posted by Benjamin <be...@netyantra.com>.
Wot is the default directory into which this IfDefine directive will 
look for the said script.

I tried all combinations under /home/user/apache/ , 
/home/user/apache/conf, /home/user/apache/bin/ or the directory from 
where I call httpd.
the directive inside httpd.conf looks somethign like this:

<IfDefine IPAvailable>
Listen 12.34.56.89:80
</IfDefine>

Unless i specify the complete path in the IfDefine like :
<IfDefine /home/user/apache/IPavailable>
Listen 12.34.56.89:80
</IfDefine>

and also along with the -D option for httpd
ie. httpd -D /home/user/apache/IPavailable

it duz not seem to work.

Shud the script be under the ServerRoot , which is /home/user/apache/ for me.





Joshua Slive wrote:

>On Thu, 10 Mar 2005 15:21:46 +0530, Benjamin <be...@netyantra.com> wrote:
>  
>
>>Is there any way to tell apache to check the existence of the IP, if not
>>do something else.
>>    
>>
>
>Not that I know of.  I would simply write a simple script that checked
>if the IP was available and started apache with, for example
>"apachectl -D IPAvailable".  Then you can include in your config an
><IfDefine IPAvailable> section that will only be used in that case.
>
>Joshua.
>
>---------------------------------------------------------------------
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:http://httpd.apache.org/userslist.html> for more info.
>To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>For additional commands, e-mail: users-help@httpd.apache.org
>
>  
>

-- 

Benjamin Jacob.

Disclaimer :
------------------------------------------------------------------------------
If you are not the intended recipient of this transmission to whom it is
addressed, or have received this transmission in error, you are hereby
notified that any dissemination, distribution or copying of this transmission
is strictly prohibited. Please notify us immediately and delete this e-mail
from your system. The sender does not accept liability for any errors or
omissions in the contents of this message which arise as a result of e-mail
transmission, which cannot be guaranteed to be secure or error-free as
information could be intercepted, corrupted, lost, destroyed, arrive late or
incomplete, arrive at wrong address or contain viruses. If verification
is required please request a hard-copy version.  This e-mail contains only the
personal opinions of the sender and does not represent an official
communication from NetYantra of any manner.
------------------------------------------------------------------------------


Re: [users@httpd] conditonal listen???

Posted by Joshua Slive <js...@gmail.com>.
On Thu, 10 Mar 2005 15:21:46 +0530, Benjamin <be...@netyantra.com> wrote:
> Is there any way to tell apache to check the existence of the IP, if not
> do something else.

Not that I know of.  I would simply write a simple script that checked
if the IP was available and started apache with, for example
"apachectl -D IPAvailable".  Then you can include in your config an
<IfDefine IPAvailable> section that will only be used in that case.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org