Hack (web) and apache configuration

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 </Location> but the pathInfo field is always null. Env {requestMethod = GET, scriptName = "/lambda", pathInfo = "", queryString = "input=lambda", serverName = "127.0.0.1", serverPort = 80, http = [("FCGI_ROLE","RESPONDER"),("SCRIPT_URL","/lambda"), ("SCRIPT_URI","http://127.0.0.1/lambda"),("User-Agent","curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18"), ("Host","127.0.0.1"),("Accept","*/*"),("PATH","/usr/local/bin:/usr/bin:/bin"), ("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 127.0.0.1 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_NAME","127.0.0.1"),("SERVER_ADDR","127.0.0.1"), ("SERVER_PORT","80"),("REMOTE_ADDR","127.0.0.1"), ("DOCUMENT_ROOT","/home/henry/maztrave2/www/fcgi"), ("SERVER_ADMIN","[no address given]"), ("SCRIPT_FILENAME","/home/henry/maztrave2/www/fcgi/hackTest"), ("REMOTE_PORT","44936"), ("GATEWAY_INTERFACE","CGI/1.1"),("SERVER_PROTOCOL","HTTP/1.1"), ("REQUEST_METHOD","GET"),("QUERY_STRING","input=lambda"), ("REQUEST_URI","/lambda"),("SCRIPT_NAME","/lambda")], hackVersion = [2009,5,19], hackUrlScheme = HTTP, hackInput = Empty, hackErrors = HackErrors, hackHeaders = []}% I think what I want is to have all URLS, such as: http://127.0.0.1/lambda 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 following: 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 web. Thanks in advance for your help. Best wishes, Henry Laxen

Henry Laxen wrote:
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 </Location>
but the pathInfo field is always null.
Path info is path-like data that directly follows the name of the resource being referenced, e.g.: /myfiles/foo.html/this/is/path/info A rule that would give you path info in the case you describe would be more like this: RewriteRule ^/(.*)$ /hackTest/$1 [T=application/x-httpd-cgi] Whether that works depends on how /hackTest is being dispatched, but if Hack expects pathinfo, then it may just work. Anton

Anton van Straaten
Path info is path-like data that directly follows the name of the resource being referenced, e.g.: /myfiles/foo.html/this/is/path/info
A rule that would give you path info in the case you describe would be more like this:
RewriteRule ^/(.*)$ /hackTest/$1 [T=application/x-httpd-cgi]
Whether that works depends on how /hackTest is being dispatched, but if Hack expects pathinfo, then it may just work.
Anton
Dear Anton, Thank you, that works perfectly. That's what I love about programming, just change a single character, and the world goes from total chaos to perfect order. It reminds me of a saying I heard once. If carpenters built houses the way programmers write programs, you could walk into any house, remove any single nail, and the structure would collapse into pieces no larger than toothpicks. Thanks again. Henry

On Jun 25, 2009, at 13:31 , Henry Laxen wrote:
It reminds me of a saying I heard once. If carpenters built houses the way programmers write programs, you could walk into any house, remove any single nail, and the structure would collapse into pieces no larger than toothpicks.
Weinberg's Law: "If carpenters built houses the way programmers write programs, then the first woodpecker that came along would destroy civilization." -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (4)
-
Anton van Straaten
-
Brandon S. Allbery KF8NH
-
Henry Laxen
-
Simon Michael