Include multiple cgi-bins for virtualhosts?

Hi,

Quick question… I am trying to have a cgi-bin setup for cgi scripts that my virtualhosts have access to using

ScriptAlais /cgi-bin/ "/path/to/public/cgi-bin"

While this is fairly easily achieved, but at the same time I'd also like to have private cgi-bins for each of my virtual hosts in by using ScriptAlias /cgi-bin/ "/path/to/virtualhost/cgi-bin/"

I have tested this method and have had strange results… such as "www.virhostdomain.com/cgi-bin/program.cgi" returning a 404 Not Found message. BUT if I enter "mail.virhostdomain.com/cgi-bin/program.cgi", it's finds the path fine!!

Is what I am trying to do even possible? Basically I just want a public cgi-bin and a private one. Too much to ask of apache?

I am running slackware 10 (small) w/ apache 1.3.31.

Thank you…

5 Replies

It should certainly work, yes. My guess is there's something else going on.

What do the sections in your httpd.conf look like?

Thanks for your reply…. Here's how my directive looks like…

 <virtualhost *="">ServerName www.virtualhost_domain.com
ServerAlias virtualhost_domain.com
ServerAdmin postmaster@virtualhost_domain.com
ScriptAlias /cgi-bin/ /home/virtualhost_domain/cgi-bin/
DocumentRoot /home/virtualhost_domain/public_html
ErrorLog /home/virtualhost_domain/logs/error_log
CustomLog /home/virtualhost_domain/logs/access_log common
 <directory home="" virtualhost_domain="" public_html="">Options Indexes IncludesNOEXEC FollowSymLinks</directory></virtualhost> 

This is how ScriptAlias looks like for the public cgi-bin in the [IfModule] directive:

ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"
 <directory "="" home="" www="" cgi-bin"="">AllowOverride None
        Options None
        Order allow,deny
        Allow from all</directory> 

Is this how I should be defining the private "ScriptAlias" for the virtualhost's own cgi-bin?

My experience has been that it's far easier (ie. less hassle) to define all hosts as VirtualHosts, otherwise things are just weird. In my experience, when VirtualHosts are used, the first one defined is used as the main host. So, what I would suggest first is making sure that any directives such as ScriptAlias, etc, appear only in VirtualHost tags. Basically, the best idea is to remove as many host-specific things from the main part of httpd.conf as you can, including things like ScriptAlias. The stuff like AddModule, etc. aren't host-specific, so they can stay there.

So basically, you want to set up two VirtualHost tags, the first one being the main site and the second being the private one. That doesn't sound like it should work, but using VirtualHosts in combination with another host defined outside of a VirtualHost tag can cause weird problems, so it might well work for you. Give it a go, and let me know how it works out. If it doesn't work out, post what you have, and then we can try some more. :D

I agree. I have always had better luck by defining all possible hosts as virtual hosts. Here is some fun reading on the 1.3 host directives: http://httpd.apache.org/docs/vhosts/details.html and the first one in the examples link shows pretty much that idea of having the main host respond to nothing: http://httpd.apache.org/docs/vhosts/examples.html

Simply magical! Thanks guys… Here's what I did….

In the main_host, I commented out

#ScriptAlias /cgi-bin/ "/path/to/main_host/cgi-bin/"
    # <directory "="" path="" to="" cgi-bin"="">#   AllowOverride None
     #   Options None
     #   Order allow,deny
     #   Allow from all
    #</directory>

And then I took that same code into my vhost file and did:

 <virtualhost *="">ServerName *
ServerAlias *
ScriptAlias /cgi-bin/ /path/to/main_host/cgi-bin/
 <directory path="" to="" main_host="" cgi-bin="">AllowOverride None
Options None
Order allow,deny
Allow from all</directory></virtualhost> 

And keeping the vhost directive the way it was:

 <virtualhost *="">ServerName www.my_vhost.com
ServerAlias my_vhost.com
ScriptAlias /cgi-bin/ /path/to/my_vhost/cgi-bin/
DocumentRoot /path/to/my_vhost/public_html
ErrorLog /path/to/my_vhost/logs/error_log
CustomLog /path/to/my_vhost/logs/access_log common
 <directory path="" to="" my_vhost="" public_html="">Options Indexes IncludesNOEXEC FollowSymLinks</directory></virtualhost> 

And now it seems to be responding to both the main_host cgi scripts as well as vhost's own! Thank you guys! :o

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct