Forum

CGI, no extension, EnablePathInfo

JanH
15 October 2010, 11:14
Hello Hugo,

I'm having a hard time configuring Hiawatha for serving TWiki and TRAC on our company's intranet server.
They both are written as cgi scripts with no extensions, and parameters in URL after a slash.

For example, this works:
http://intranet/cgi-bin/twiki/view


Link like this causes a 404 error:
http://intranet/cgi-bin/twiki/view/Main/WebHome


The actual CGI script here is of course view.

The server configuration is as follows
(Shortened, one VirtualHost served on port 443 left out):

# GENERAL SETTINGS
ServerId = www-data
ConnectionsTotal = 1500
ConnectionsPerIP = 100
SocketSendTimeout = 30
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log

# BINDING SETTINGS
Binding {
Port = 80
MaxKeepAlive = 300
TimeForRequest = 30,100
MaxUploadSize = 16
}

# BANNING SETTINGS
BanOnMaxPerIP = 20
BanOnFlooding = 25/2:30
BanOnWrongPassword = 3:30

# COMMON GATEWAY INTERFACE (CGI) SETTINGS
CGIhandler = /usr/bin/python:py
CGIhandler = /usr/bin/perl:pl
CGIhandler = /usr/bin/php-cgi:php,php4,php5
CGIextension = cgi
KillTimedoutCGI = yes
NoExtensionAs = cgi

VirtualHost {
Hostname = intranet
WebsiteRoot = /data/intranet
StartFile = index.php
RequireSSL = no
ShowIndex = no
SecureURL = no
FollowSymlinks = yes
TimeForCGI = 120
ExecuteCGI = yes
EnablePathInfo = yes
Alias = /intranet:/data/intranet
Alias = /phpmyadmin:/usr/share/phpmyadmin
Alias = /cgi-bin:/usr/lib/cgi-bin
}



I found similar issues here http://www.hiawatha-webserver.org/forum/topic/514
and here http://www.hiawatha-webserver.org/forum/topic/269, but that doesn't work for me.
As you can see, there is EnablePathInfo directive present, but of course that doesn't apply without extensions.

Is there a possibility to execute these CGI scripts directly, without FastCGI?
If not, how the configuration should look like? TWiki is written in PERL, and TRAC is written
in Python. Clearly, I'd like to avoid the hassle with setting FastCGI servers for that.

NOTE:
I just tried to create a link to view called view.cgi, and I get the same error 404 for
http://intranet/cgi-bin/twiki/view.cgi/Main/WebHome. Maybe I misconfigured something, could you point
me to the right direction?

Thanks.

Hiawatha Version: 7.3
OS: Ubuntu 8.04.3 LTS Server
Hugo Leisink
15 October 2010, 13:04
You could try the NoExtensionAs setting. Problem is that it's a 'global' setting. In other words, this setting applies to all hosts. I've already changed this for 7.4, in which it will be a setting per host.

You could use the NoExtensionAs for the TRAC website and try another wiki. In my opinion, web applications that depend on PathInfo are not well written. Try MediaWiki or DocuWiki. Wikipedia is using MediaWiki, that should say something.

Other option is to use NoExtension for the Twiki and FastCGI for TRAC. If you setup TRAC with Hiawatha and FastCGI, please send your configuration to the TRAC team for their TRAC FastCGI HOWTO [trac.edgewall.org] page.
JanH
15 October 2010, 23:38
I found the problem

I was wrong in my first post. You are right, EnablePathInfo directive works also for URL's, where CGI script without an extension is present. The NoExtensionAs directive is needed for this to work. So why EnablePathInfo wasn't working for me, no matter what the script name was?

The problem was caused by the last line of my configuration:
Alias = /cgi-bin:/usr/lib/cgi-bin

EnablePathInfo doesn't work for aliased paths. Is this behaviour intentional, or is it a bug? If it's for purpose, it would be nice to mention that in the manpages under EnablePathInfo somewhere.

Solution:
I deleted the alias line for cgi-bin, and linked the directory in the filesystem instead:
ln -s /usr/lib/cgi-bin /data/intranet/cgi-bin

Then, the important lines in the configuration are:
...
CGIextension = cgi
NoExtensionAs = cgi

VirtualHost {
Hostname = intranet
WebsiteRoot = /data/intranet
FollowSymlinks = yes
ExecuteCGI = yes
EnablePathInfo = yes
Setenv TRAC_ENV_PARENT_DIR = /data/trac/
# ... more parameters, blahblah ...
}

My original config was OK, except for the last "Alias" line. And I also had to add the Setenv line for TRAC. This parameter is usually to be found in /etc/apache2/conf.d/trac.conf for apache config.

This setup may look a bit messy for Hiawatha standards, but still a lot cleaner compared to what Apache is able to offer

NOTE:
I'd like to use MediaWiki, but the data migration process from current TWiki is too much work for little gain.
I also have no intention to configure TRAC with FastCGI for now.

Thanks again for your response.
This topic has been closed.