You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by ms...@freezone.co.uk on 2004/12/04 05:55:08 UTC

[users@httpd] "if CGI enabled" condition

How can we make some directives conditional, depending on whether CGI 
execution is enabled?

We tried:

	<IfModule mod_cgi.c>
		Action filter /~ucc/filter.sh
		SetHandler filter
	</IfModule>

But these directives are used even when CGI execution is disabled, 
since (I guess) mod_cgi.c is still loaded.

Any suggestions?

Many thanks!

Jack


---------------------------------------------------------------------
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] "if CGI enabled" condition

Posted by Joshua Slive <js...@gmail.com>.
On Sun, 19 Dec 2004 13:44:48 -0800, ms419@freezone.co.uk
<ms...@freezone.co.uk> wrote:
> On Dec 11, 2004, at 2:03 PM, Joshua Slive wrote:
> > On Sat, 11 Dec 2004 10:01:04 -0800, ms419@freezone.co.uk
> > <ms...@freezone.co.uk> wrote:
> >> Thanks Joshua - a good suggestion - but the two cases I need to
> >> distinguish between, where CGI is enabled & not, are configured in
> >> virtual hosts of the same server. I gave -DCGI a try, but since we run
> >> only one server, I don't think I can define "CGI" in one case & not
> >> the
> >> other.
> >>
> >> Pity there is no way, as you say, to test whether CGI is enabled.
> >> Might
> >> this be a reasonable feature request?
> >
> > Your requirements are not clear.  Exactly what are you trying to do
> > and why?  If you have one host with CGI enabled and other without,
> > then just put the directives you want into the <VirtualHost> container
> > for the relevant host.
> 
> Sorry! I should have mentioned that the directives:
> 
>        Action filter /~ucc/filter.sh
>        SetHandler filter
> 
> must be in .htaccess files.
> 
> We run two virtual hosts: www.sfu.ca & cgi.sfu.ca. filter.sh can be run
> only on cgi.sfu.ca, but the server is home to tens of thousands of
> users, & policy prevents us from putting any project specific
> configuration in the main server configuration files.
> 
> So we run only one server, & can use only one configuration, yet
> somehow we must make these directives effective only if CGI is enabled.

Yep, well.... Apache offers several different ways to do exactly what
you want, but you seem to have "policy" preventing you from using
them.  Time to change your policy if you really need that feature.

Of course, as with most apache problems, this one could be solved with
mod_rewrite if you have access to that.
RewriteCond %{HTTP_HOST} ^cgi.sfu.ca$ [NC]
RewriteRule (.*) /~ucc/filter.sh/$1
(Untested; may need to be adjusted for RewriteBase.)

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] "if CGI enabled" condition

Posted by ms...@freezone.co.uk.
On Dec 11, 2004, at 2:03 PM, Joshua Slive wrote:
> On Sat, 11 Dec 2004 10:01:04 -0800, ms419@freezone.co.uk
> <ms...@freezone.co.uk> wrote:
>> Thanks Joshua - a good suggestion - but the two cases I need to
>> distinguish between, where CGI is enabled & not, are configured in
>> virtual hosts of the same server. I gave -DCGI a try, but since we run
>> only one server, I don't think I can define "CGI" in one case & not 
>> the
>> other.
>>
>> Pity there is no way, as you say, to test whether CGI is enabled. 
>> Might
>> this be a reasonable feature request?
>
> Your requirements are not clear.  Exactly what are you trying to do
> and why?  If you have one host with CGI enabled and other without,
> then just put the directives you want into the <VirtualHost> container
> for the relevant host.

Sorry! I should have mentioned that the directives:

	Action filter /~ucc/filter.sh
	SetHandler filter

must be in .htaccess files.

We run two virtual hosts: www.sfu.ca & cgi.sfu.ca. filter.sh can be run 
only on cgi.sfu.ca, but the server is home to tens of thousands of 
users, & policy prevents us from putting any project specific 
configuration in the main server configuration files.

So we run only one server, & can use only one configuration, yet 
somehow we must make these directives effective only if CGI is enabled.

Many thanks for your help, & sorry I wasn't clear!

Jack


---------------------------------------------------------------------
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] "if CGI enabled" condition

Posted by Joshua Slive <js...@gmail.com>.
On Sat, 11 Dec 2004 10:01:04 -0800, ms419@freezone.co.uk
<ms...@freezone.co.uk> wrote:
> Thanks Joshua - a good suggestion - but the two cases I need to
> distinguish between, where CGI is enabled & not, are configured in
> virtual hosts of the same server. I gave -DCGI a try, but since we run
> only one server, I don't think I can define "CGI" in one case & not the
> other.
> 
> Pity there is no way, as you say, to test whether CGI is enabled. Might
> this be a reasonable feature request?

Your requirements are not clear.  Exactly what are you trying to do
and why?  If you have one host with CGI enabled and other without,
then just put the directives you want into the <VirtualHost> container
for the relevant host.

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] "if CGI enabled" condition

Posted by ms...@freezone.co.uk.
On Dec 4, 2004, at 6:59 AM, Joshua Slive wrote:
> On Fri, 3 Dec 2004 20:55:08 -0800, ms419@freezone.co.uk
> <ms...@freezone.co.uk> wrote:
>> How can we make some directives conditional, depending on whether CGI
>> execution is enabled?
>
> There is no direct way.  But you can use an <IfDefine> combined with
> the -D command line option to enclose both your CGI-activation
> directives and any other directives which depend on them.

Thanks Joshua - a good suggestion - but the two cases I need to 
distinguish between, where CGI is enabled & not, are configured in 
virtual hosts of the same server. I gave -DCGI a try, but since we run 
only one server, I don't think I can define "CGI" in one case & not the 
other.

Pity there is no way, as you say, to test whether CGI is enabled. Might 
this be a reasonable feature request?

Thanks again,

Jack


---------------------------------------------------------------------
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] "if CGI enabled" condition

Posted by Joshua Slive <js...@gmail.com>.
On Fri, 3 Dec 2004 20:55:08 -0800, ms419@freezone.co.uk
<ms...@freezone.co.uk> wrote:
> How can we make some directives conditional, depending on whether CGI
> execution is enabled?

There is no direct way.  But you can use an <IfDefine> combined with
the -D command line option to enclose both your CGI-activation
directives and any other directives which depend on them.

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