Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI include gives its source

Status
Not open for further replies.

mimics

Programmer
Jun 22, 2003
13
SI
Hi!

I have the following problem. I have a CGI program
(counter) and if I called it directly it works OK,
but if I include it with "include virtual" I get
its source code. Please help!


Mike
P.S.: That's my config file:

User apache
Group apache

...

DocumentRoot /var/
<Directory />
Options -Indexes none
AllowOverride None
Order Deny,Allow
Deny from All
</Directory>

<IfModule mod_userdir.c>
UserDir public_html
</IfModule>

...

AddType text/html .html
AddHandler server-parsed .html
AddType text/html .shtml
AddHandler server-parsed .shtml

...

<Directory /var/ Options -Indexes IncludesNOEXEC
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

<IfModule mod_perl.c>
<Directory /var/ Options -Indexes ExecCGI IncludesNOEXEC
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
</Directory>
</IfModule>

<Directory /var/ Options -Indexes
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

<Directory /home/*/public_html>
Options -Indexes IncludesNOEXEC
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
 
I don't know where you got all that or what it does but I did notice that you don't have a ScriptAlias directive for your cgi directory. I also noticed that you have your cgi-bin under your html directory which means that your cgi directory and all its subs takes on the properties of the html directory unless you redefine it. If you use ScriptAlias you could set directives for your cgi-bin and not have to tell it to forget how you told it to treat other directories. Makes it a lot easier to trouble shoot too.
 
Hi,

Have you set up SSI ? Include virtual is a SSI tag and won't work without it. You need to activate mod_include in your httpd.conf (probably is on by default as its part of the base system) :

LoadModule includes_module modules/mod_include.so

AddModule mod_include.c

AddType text/html .shtml

AddHandler server-parsed .shtml

(check the path argument on the LoadModule above - it may be different on your installation of Apache)

Restart ... 'killall -HUP httpd'

Then try something like :

<HTML>
<HEAD>
<TITLE>Test Page</TITLE>
</HEAD>
<BODY>
<center>
<H1>Virtual SSI Tag test</H1>
</center>
<!--#include virtual=&quot;/cgi-bin/your.cgi&quot; -->
</BODY>
</HTML>


Also remember that the 'path' on include virtual is a relative URL and not an absolute path to a file.

Hope this helps
 
Thanks for replies.

I use SSI through all my site (&quot;normal&quot; text virtual includes), so that isn't the problem.

I had some problems so I have to move the cgi-bin directory to html directory. Same problem had somebody else (&quot;Server Side Includes sort of work...???&quot;), but its solution (reinstalling Apache) didn't work for me, so I have discovered that with enabled ScriptAlias cgi-program works OK but when I tryed to include it, server searches the file as there where no ScriptAlias (from the html root) and so it doesn't find it and throws an error. So I moved the cgi-bin directory, redefined Apache to support that directory and now again cgi-program works but when I try to include it, server doesn't recognize that directory is cgi-bin. But I have redefined it, so ... My question is why Apache doesn't consider confs when I use SSI?
 
Hi,

As you have IncludesNOEXEC then you can't use #exec CGI and can only use #include virtual CGI scripts and these must be from ScriptAliase'd directories. It should work if you setup a ScriptAlias and the cgi directory has the following :

Options ExecCGI Includes
or
Options ExecCGI IncludesNOEXEC

On the conf problem - are you sure you restarted the server or signalled it to re-read the config?

Regards
 
I have restarted the whole computer and it's the same. I can't get (Script)Aliasing working. It works when I call it directly but when I include that file it search it in html directory.
Can maybe someone sends me its working config files (if it use include virtual to include cgi output and it works for him).

Maybe is something wrong in Apache's proxy configuration? I know that I have to rewrite the rule so that it was serving the /cgi/ bin as cgi directory (I have just replaced default name /perl/ with /cgi/).
 
Ah, yes. The e-mail would be nice. :)

ppagee@yahoo.com
 
Hi!

I have new (better?) situation.

I have the cgi-bin with counter perl program in it. But the problem is that when I call it directly program works (counts), but when I try to include it into html I get error.

[...] [error] [client ...] client denied by server configuration: /var/[...] [error] [client ...] unable to include &quot;/cgi/counter&quot; in parsed file /var/
This is my conf file:

User apache
Group apache
...
DocumentRoot /var/<Directory />
Options -Indexes none
AllowOverride None
Order Deny,Allow
Deny from All
</Directory>
...
<IfModule mod_alias.c>
...
ScriptAlias /cgi/ /var/</IfModule>
...
<Directory /var/ Options -Indexes Includes
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

<IfModule mod_perl.c>
PerlModule Apache::Registry
<Directory /var/ Options -Indexes ExecCGI Includes
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
<Location /cgi>
Options -Indexes ExecCGI Includes
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
</Location>
</IfModule>
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top