Forum

Perl CGI Working Well With thttpd, Oddly w/ Hiawatha

cmholm
8 December 2010, 04:32


Hiawatha version: 7.3
Operating System: OS X 10.5.8, Intel

I've used the My Photo Gallery cgi from fuzzymonkey.net for years on both PPC Debian Lynx, and various versions of OS X PPC and now Intel, all running under the thttpd web server. I wanted fast cgi to support Mediawiki, so I've moved from thttpd to Hiawatha. This has enabled me to consolidate my httpd and https servers. My existing CGIs, both vanilla Perl and Fastcgi PHP are working as expected... with one exception.

My Photo Gallery includes a "manage.cgi" with "settings", "tools", and "manage" modes, with hrefs like www.foo.com/cgi-bin/photo/protected/manage.cgi?mode=tools. The settings and tools logic crank out the expected html. The manage mode has the following behavior after clicking on the 'manage' link within the cgi's html menu (or commanding the mode from console):

1. FF: nothing, the manage.cgi menu page sits there.
2. Safari: 'can't open the page, ?The operation couldn?t be completed. (kCFErrorDomainCFNetwork error 303.)?.
3. lynx: responds correctly
4. sudo perl -w ./manage.cgi mode=manage: spits out the appropriate html.

It seems that the unchanged Perl code is capable of functioning as designed, and the browsers didn't have an issue when the cgi was served up via thttpd. So, I'm guessing my configuration is off. Any hints are appreciated.

I'm happy to provide the entire hiawatha.conf file, but in the interest of brevity I'll just include the following fragments here:

Binding {
Port = 80
Interface = 192.168.1.1
}
CGIhandler = /opt/local/bin/perl:cgi
CGIextension = cgi
VirtualHost {
Hostname = foo.org,www.foo.org,*.foo.org
WebsiteRoot = /Users/me/Sites/foo
StartFile = index.html
AccessLogfile = /usr/local/var/log/hiawatha/192.168.1.1/org.foo.access.log
ErrorLogfile = /usr/local/var/log/hiawatha/192.168.1.1/org.foo.error.log
ExecuteCGI = yes
TimeForCGI = 15
}
Directory {
Path = /Users/me/Sites/foo/cgi-bin/photo/protected
ExecuteCGI = yes
PasswordFile = basic:.htpasswd
UploadSpeed = 10,2
}


Hugo Leisink
8 December 2010, 15:15
The following configuration causes a conflict:
CGIhandler = /opt/local/bin/perl:cgi
CGIextension = cgi

CGIhandler tells Hiawatha to use an interpreter (perl in this case) to handle .cgi files. CGIextension tells Hiawatha to directly run .cgi files. You can't use two methods for one and the same extension. The tool 'wigwam' that comes with Hiawatha should have warned you about this. Didn't you use it?

The solution is to remove one of them. Which one depends on how the .cgi files should be handled. If they have the filesystem executable flag and all start with "#!/opt/local/bin/perl", you can use CGIextension. Otherwise, you should use the CGIhandler option.

It's all explained in the CGI HOWTO page.
This topic has been closed.