[Haskell-cafe] Hack (web) and apache configuration

Henry Laxen nadine.and.henry at pobox.com
Thu Jun 25 11:37:53 EDT 2009

Dear Group,

I am posting this here even though it probably belongs on the
apache list because I suspect other haskell users will be able to
find it here more easily.  I am playing around with hack, and am
having trouble with configuring apache with fastcgi to make
things work.  My understanding of the "hack" concept is that it
provides a stardardized interface that lets you glue together
web "Applications".  It also provides several front-ends, such as
happs, and fastcgi etc.  Now based on looking at the Middleware
supplied with hack, it seems to be trying to dispatch based on
the contents of the pathInfo field of the Env record.  So, my
question is, how do we configure Apache2 with the fastcgi handler
so that something appears in the pathInfo field?

I have tried several things, the most recent being:

RewriteEngine on
RewriteRule ^/(.*)$ /hackTest?input=$1 [T=application/x-httpd-cgi]
<Location />
    SetHandler fastcgi-script
    Options ExecCGI FollowSymLinks

but the pathInfo field is always null.  

Env {requestMethod = GET, scriptName = "/lambda", pathInfo = "", 
queryString = "input=lambda", serverName = "", serverPort = 80, 
http = [("FCGI_ROLE","RESPONDER"),("SCRIPT_URL","/lambda"),
(x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/ libidn/1.8
("SERVER_SIGNATURE","<address>Apache/2.2.9 (Debian) mod_fastcgi/2.4.6
proxy_html/3.0.0 mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0 Server at Port 80</address>\n"),
("SERVER_SOFTWARE","Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 proxy_html/3.0.0
mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0"),
("SERVER_ADMIN","[no address given]"),
hackVersion = [2009,5,19], hackUrlScheme = HTTP, hackInput = Empty, hackErrors =
HackErrors, hackHeaders = []}% 

I think what I want is to have all URLS, such as:

be dispatched though my hackTest executable, without having to go
through the rewrite, but I can't convice apache to do that.  In
the interest of completeness, my hackTest.hs file is the

import Hack
import Hack.Handler.FastCGI
import Data.ByteString.Lazy.Char8 (pack)
import Hack.Contrib.Middleware.Lambda

app :: Application
app = \env ->   return $ Response
        { status  = 200
        , headers = [ ("Content-Type", "text/plain") ]
        , body    = pack $ show env

main = runFastCGIorCGI $ lambda app


One final comment to the authors of hack.  Would you please
consider renaming this project.  hack is such a common word that
has nothing to do with this project that it make searching the
web with google, etc. almost useless.  I realize it is a clever
respelling of the ruby version "rack", but please consider naming
it something more unique, while it is still relatively new on the

Thanks in advance for your help.
Best wishes,
Henry Laxen

More information about the Haskell-Cafe mailing list