I might have asked this question earlier, but in any case, here goes again. 
Hopefully one of knowledgable folks can guide me toward the right path.

I have my Dancer app running behind an Apache2 proxy, so when the user goes to 
`http://server/app`, apache serves content retrieved from 
`http://127.0.0.1:port/` that is being served by Starman+Dancer.

My application also serves maps via Apache+MapServer from 
`http://server/cgi-bin/mapserv`. 

In reality, I have not just `/app` but `/app1`, `/app2`, `/app3` and so on. In 
order to send `/app<n>` specific MapServer information to the cgi program, I 
have shell script wrappers called `app1`, `app2`, `app3` in my cgi-bin 
directory. Their content is like so ("app<n>.map" is a "mapfile" for app<n>. 
There is one for each app).

    #!/bin/sh

    MAPSERV="/path/to/punkish/cgi-bin/mapserv"
    MAPFILE="/path/to/app<n>.map"
    if [ "${REQUEST_METHOD}" = "GET" ]; then
        if [ -z "${QUERY_STRING}" ]; then
            QUERY_STRING="map=${MAPFILE}"
        else
            QUERY_STRING="map=${MAPFILE}&${QUERY_STRING}"
        fi
        exec ${MAPSERV}
    else
        echo "Sorry, I only understand GET requests."
    fi
    exit 1

With that background, I now have all my app-specific stuff in my Dancer 
directory, except this shell script that is in the apache cgi-bin directory. 
This makes management difficult, and I would like to move these files to the 
Dancer directory. Except, I haven't been able to figure out how to execute 
apache cgi-bin programs from Dancer. I tried the following in my app but I get 
a 502 Proxy Error.

    # http://server/app/ms
    get '/ms' => sub {
        my $MAPSERV = '/path/to/punkish/cgi-bin/mapserv';
        my $MAPFILE = '/path/to/app.map';
    
        my $params = params();
        my $QUERY_STRING = "";
        while (my ($k, $v) = each %$params) {
            $QUERY_STRING .= "$k=$v";
        }
        $QUERY_STRING .= "&$MAPFILE";
        
        exec("$MAPSERV $QUERY_STRING");
    };

In other words, I want to take the /ms route and send it off to Apache to 
execute (via Apache's cgi interface) and return the content via Dancer. That 
sounds like I want to use Dancer as a proxy for Apache while Apache is already 
a proxy for Dancer, but actually, all I want is to store certain files under 
the Dancer app directory, but let Apache handle them instead of Dancer.

Suggestions? 

--
Puneet Kishor

_______________________________________________
Dancer-users mailing list
[email protected]
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users

Reply via email to