.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Plack::App::Proxy 3pm" .TH Plack::App::Proxy 3pm "2021-01-09" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Plack::App::Proxy \- proxy requests .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Plack::Builder; \& \& # proxy all requests for /static to 127.0.0.1:80 \& builder { \& mount "/static" => Plack::App::Proxy\->new(remote => "http://127.0.0.1:80")\->to_app; \& }; \& \& # Call from other app \& my $proxy = Plack::App::Proxy\->new\->to_app; \& my $app = sub { \& my $env = shift; \& ... \& $env\->{\*(Aqplack.proxy.url\*(Aq} = $url; \& $proxy\->($env); \& }; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Plack::App::Proxy is a middleware-aware proxy application for Plack. .SH "OPTIONS" .IX Header "OPTIONS" .IP "remote" 4 .IX Item "remote" .Vb 1 \& Plack::App::Proxy\->new(remote => \*(Aqhttp://perl.org\*(Aq)\->to_app; .Ve .Sp Specifies the base remote \s-1URL\s0 to proxy requests to. .Sp .Vb 4 \& builder { \& mount "/example", \& Plack::App::Proxy\->new(remote => \*(Aqhttp://example.com/app/foo\*(Aq)\->to_app; \& }; .Ve .Sp This proxies incoming requests for \f(CW\*(C`/example/bar\*(C'\fR proxied to \&\f(CW\*(C`http://example.com/app/foo/bar\*(C'\fR. .IP "preserve_host_header" 4 .IX Item "preserve_host_header" Preserves the original Host header, which is useful when you do reverse proxying to the internal hosts. .IP "backend" 4 .IX Item "backend" The \s-1HTTP\s0 backend to use. This dist comes with \f(CW\*(C`LWP\*(C'\fR and \f(CW\*(C`AnyEvent::HTTP\*(C'\fR backends. \f(CW\*(C`AnyEvent::HTTP\*(C'\fR is the default if no backend is specified. .IP "options" 4 .IX Item "options" The options for the \s-1HTTP\s0 backend instance. .SH "MIDDLEWARE CONFIGURATIONS" .IX Header "MIDDLEWARE CONFIGURATIONS" This application is just like a normal \s-1PSGI\s0 application and is middleware aware, which means you can modify proxy requests (and responses) using Plack middleware stack. .PP It also supports the following special environment variables: .IP "plack.proxy.url" 4 .IX Item "plack.proxy.url" Overrides the proxy request \s-1URL.\s0 .IP "plack.proxy.remote" 4 .IX Item "plack.proxy.remote" Overrides the base \s-1URL\s0 path to proxy to. .PP For example, the following builder code allows you to proxy all \s-1GET\s0 requests for .png paths to the lolcat image (yes, a silly example) but proxies to the internal host otherwise. .PP .Vb 10 \& my $mw = sub { \& my $app = shift; \& sub { \& my $env = shift; \& if ($env\->{REQUEST_METHOD} eq \*(AqGET\*(Aq && $env\->{PATH_INFO} =~ /\e.png$/) { \& $env\->{\*(Aqplack.proxy.url\*(Aq} = \*(Aqhttp://lolcat.example.com/lol.png\*(Aq; \& } \& $app\->($env); \& }; \& }; \& \& use Plack::Builder; \& \& builder { \& enable $mw; \& Plack::App::Proxy\->new(remote => \*(Aqhttp://10.0.0.1:8080\*(Aq)\->to_app; \& }; .Ve .SH "AUTHOR" .IX Header "AUTHOR" Lee Aylward .PP Masahiro Honma .PP Tatsuhiko Miyagawa .PP Jesse Luehrs .SH "LICENSE" .IX Header "LICENSE" This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" Plack::Builder