[Dancer-users] CGI/FCGI deployment & uri_for

Robert Olson bob at rdolson.org
Thu Dec 30 01:06:45 CET 2010


Looking further, I'm seeing various things for doing rewrites of  
SCRIPT_NAME for reverse proxies, but not for the rewrite rules of the  
form used for the fcgi/cgi deployment.

I'm not sure if this is a good solution or not but plack lets me  
define a middleware:

package FixScriptName;
use parent qw(Plack::Middleware);

use strict;

sub call
{
     my($self, $env) = @_;
     $env->{SCRIPT_NAME} =	'';
     return $self->app->($env);
}

1;

which I can then enable in config.yml:

plack_middlewares:
   -
     - +FixScriptName


and uri_for does what I want it to, in this case anyway.

I tried to set up a dancer psgi file to use the Plack Builder DSL to  
do configs, but couldn't get it to go right. It seems a little inside  
out to define the middleware stack for a dancer app inside the dancer  
app configuration. This hack lets me get moving on making my  
application do what I want tho.

--bob

On Dec 28, 2010, at 4:53 PM, Robert Olson wrote:

> It seems I must be doing something dumb, but I'm not seeing it.
>
> I'm putting up a dancer app for a domain hosted at dreamhost. I  
> created the app using the latest 1.2 dancer, and changed the webroot  
> for the domain to appdir/public using the DH config panel. The  
> following .htaccess is in place:
>
> AddHandler fastcgi-script .fcgi
> Options +FollowSymLinks +ExecCGI
>
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule (.*) /dispatch.cgi/$1 [QSA,L]
>
> Access to the routes works like a champ (including  
> Net::Google::FederatedLogin authentication which I may turn into a  
> plugin; also thinking about a CGI::FormBuilder plugin like  
> Catalyst's).
>
> However, uri_for returns a path that includes the rewritten path  
> with dispatch.cgi in it:
>
> uri_for("/dog") => http://<domain>/dispatch.cgi/dog
>
> I'm assuming it should instead return http://<domain>/dog.
>
> This seems like something there is an easy solution to, but I'm not  
> finding it. Does anyone have any advice?
>
> Thanks,
> --bob
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users



More information about the Dancer-users mailing list