Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Dev
nginx patch to Engine::FastCGI?
 

Index | Next | Previous | View Flat


jshirley at gmail

Oct 30, 2008, 1:35 PM


Views: 2821
Permalink
nginx patch to Engine::FastCGI?

I am working on a new nginx+fastcgi deployment, and this time the
Catalyst app is not at "/" like my previous other deployments. It
seems that nginx doesn't quite jive with Catalyst out of the box in
this case.

I'm going to just describe the problem, as my solution is far from
elegant, and hope that more Engine-centric folks can chime in with
better ideas.

nginx doesn't distinguish the request path any different than the
subsequent path info (appended to the end of the path). So,
$env{SCRIPT_NAME} and $env{PATH_INFO} are effectively the same value.
In the case of "/" this doesn't present any problem, but if your
application is at a different path ("/myapp" for example) then it
break.s

The good thing is nginx allows for arbitrary variables to be set in
the FastCGI config space, so you can explicitly set SCRIPT_NAME or
PATH_INFO. This doesn't help though with PATH_INFO always contains
information for $c->req->base to be built though.

The solution I came up with is to tell nginx to define the variables as such:

fastcgi_param SCRIPT_NAME /ems/;
fastcgi_param PATH_INFO $fastcgi_script_name; # Effectively
/ems/{PATH_INFO}

And then, in Engine::FastCGI I have this small patch, to remove the duplication:
if ( $env{SERVER_SOFTWARE} && $env{SERVER_SOFTWARE} =~ /nginx/ ) {
$env{PATH_INFO} =~ s/^$env{SCRIPT_NAME}//g;
}

This is the only way I could get the base URI to be constructed
properly. I'm not that experienced with nginx, but I couldn't find
anything at all in their documentation to help with it.

Hopefully someone has some better thoughts on this...

Thanks,
-J

_______________________________________________
Catalyst-dev mailing list
Catalyst-dev[at]lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst-dev

Subject User Time
nginx patch to Engine::FastCGI? jshirley at gmail Oct 30, 2008, 1:35 PM
    Re: nginx patch to Engine::FastCGI? chris at carline Oct 30, 2008, 6:16 PM
    Re: nginx patch to Engine::FastCGI? jshirley at gmail Oct 31, 2008, 12:52 PM
    Re: nginx patch to Engine::FastCGI? ash_cpan at firemirror Oct 31, 2008, 4:26 PM
    Re: nginx patch to Engine::FastCGI? ash_cpan at firemirror Oct 31, 2008, 4:28 PM
    Re: nginx patch to Engine::FastCGI? jshirley at gmail Oct 31, 2008, 4:42 PM
    Re: nginx patch to Engine::FastCGI? ash_cpan at firemirror Oct 31, 2008, 4:55 PM
    Re: nginx patch to Engine::FastCGI? jshirley at gmail Oct 31, 2008, 5:09 PM
    Re: nginx patch to Engine::FastCGI? syber.rus at gmail Oct 31, 2008, 5:42 PM
    Re: nginx patch to Engine::FastCGI? ash_cpan at firemirror Oct 31, 2008, 5:59 PM
    Re: nginx patch to Engine::FastCGI? jshirley at gmail Oct 31, 2008, 8:03 PM
    Re: nginx patch to Engine::FastCGI? ash_cpan at firemirror Nov 1, 2008, 7:34 AM
    Re: nginx patch to Engine::FastCGI? andy at hybridized Nov 1, 2008, 7:50 AM
    Re: nginx patch to Engine::FastCGI? jshirley at gmail Nov 1, 2008, 8:24 AM
    Re: nginx patch to Engine::FastCGI? pagaltzis at gmx Nov 2, 2008, 5:08 AM
        Re: Re: nginx patch to Engine::FastCGI? jshirley at gmail Nov 2, 2008, 6:24 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.