Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Catalyst-Engine-PSGI CPAN distribution.

Report information
The Basics
Id: 58362
Status: resolved
Priority: 0/
Queue: Catalyst-Engine-PSGI

People
Owner: Nobody in particular
Requestors: ckras [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.10
Fixed in: (no value)



Subject: Document how to enable Plack::Middleware::* modules
Currently the documentation states that when using a reverse proxy (lighttpd, nginx) you either need to enable Plack::Middleware::ReverseProxy or Plack::Middleware::ForwardedHeaders. Problem is, those who are not familiar with Plack (that's me :-)) don't know HOW to enable one of these modules. Does it require the user to extend the generated psgi file or do we need to write a full fledged builder... So, how would one enable one of these modules? Thanks.
Subject: Re: [rt.cpan.org #58362] Document how to enable Plack::Middleware::* modules
Date: Sun, 13 Jun 2010 13:31:42 -0700
To: bug-Catalyst-Engine-PSGI [...] rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa [...] gmail.com>
Read the documentation of Plack::Middleware::ReverseProxy and ForwardedHeaders and they explain how to enable that. You should also read perldoc Plack and Plack::Middleware to get the idea. Dumping those partial information in this module's documentation is not a good idea since that's a duplicate information and we don't like to maintain two different places for the same. It's also a good idea to force users to learn how to use Plack and middleware. On Sun, Jun 13, 2010 at 12:51 PM, Christiaan Kras via RT <bug-Catalyst-Engine-PSGI@rt.cpan.org> wrote: Show quoted text
> Sun Jun 13 15:51:18 2010: Request 58362 was acted upon. > Transaction: Ticket created by CKRAS >       Queue: Catalyst-Engine-PSGI >     Subject: Document how to enable Plack::Middleware::* modules >   Broken in: 0.10 >    Severity: (no value) >       Owner: Nobody >  Requestors: ckras@cpan.org >      Status: new >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=58362 > > > > Currently the documentation states that when using a reverse proxy > (lighttpd, nginx) you either need to enable > Plack::Middleware::ReverseProxy or Plack::Middleware::ForwardedHeaders. > Problem is, those who are not familiar with Plack (that's me :-)) don't > know HOW to enable one of these modules. > > Does it require the user to extend the generated psgi file or do we need > to write a full fledged builder... > > So, how would one enable one of these modules? Thanks. >
-- Tatsuhiko Miyagawa
The best what I could come up with was something like this: # app.psgi use Foo; use Plack::Builder; Foo->setup_engine('PSGI'); my $handler = sub { Foo->new->run(@_) }; builder { enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' } "Plack::Middleware::ReverseProxy"; $app; }; But this didn't work at all for me, but that's probably because I'm in the wrong direction. I also see now that in Plack::Middleware the wrap method can activate the Middleware modules. I'll try that tomorrow. Thanks.
Subject: Re: [rt.cpan.org #58362] Document how to enable Plack::Middleware::* modules
Date: Sun, 13 Jun 2010 13:58:58 -0700
To: bug-Catalyst-Engine-PSGI [...] rt.cpan.org
From: Tatsuhiko Miyagawa <miyagawa [...] gmail.com>
On Sun, Jun 13, 2010 at 1:46 PM, Christiaan Kras via RT <bug-Catalyst-Engine-PSGI@rt.cpan.org> wrote: Show quoted text
>       Queue: Catalyst-Engine-PSGI >  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=58362 > > > The best what I could come up with was something like this: > > # app.psgi > use Foo; > use Plack::Builder; > Foo->setup_engine('PSGI'); > my $handler = sub { Foo->new->run(@_) }; > > builder { >    enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' } >        "Plack::Middleware::ReverseProxy"; >    $app; > }; > > But this didn't work at all for me, but that's probably because I'm in > the wrong direction.
Because your app is named $handler and you're using a wrong variable $app to build it. use strict. and you'll catch mistakes like this easily. -- Tatsuhiko Miyagawa
Accidentally created a new ticket (RT#58364) which can be closed. This one can too. In my reply I said: "Sorry that was a bad case of copy and paste from examples. In my test case I named it $app". Using the wrap method worked to enable the middleware modules. For some reason ReverseProxy doesn't seem to work with lighttpd. ForwardedHeaders does load but doesn't seem to make a difference. I'm not intending to invest more time in it. Also, this isn't the place to discuss a possible bug in ReverseProxy. Thank you for your fast replies.