Coder Social home page Coder Social logo

plack-app-proxy's Introduction

NAME
    Plack::App::Proxy - proxy requests

SYNOPSIS
      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->{'plack.proxy.url'} = $url;
          $proxy->($env);
      };

DESCRIPTION
    Plack::App::Proxy is a middleware-aware proxy application for Plack.

OPTIONS
    remote
          Plack::App::Proxy->new(remote => 'http://perl.org')->to_app;

        Specifies the base remote URL to proxy requests to.

          builder {
              mount "/example",
                  Plack::App::Proxy->new(remote => 'http://example.com/app/foo')->to_app;
          };

        This proxies incoming requests for "/example/bar" proxied to
        "http://example.com/app/foo/bar".

    preserve_host_header
        Preserves the original Host header, which is useful when you do
        reverse proxying to the internal hosts.

    backend
        The HTTP backend to use. This dist comes with "LWP" and
        "AnyEvent::HTTP" backends. "AnyEvent::HTTP" is the default if no
        backend is specified.

MIDDLEWARE CONFIGURATIONS
    This application is just like a normal PSGI application and is
    middleware aware, which means you can modify proxy requests (and
    responses) using Plack middleware stack.

    It also supports the following special environment variables:

    plack.proxy.url
        Overrides the proxy request URL.

    plack.proxy.remote
        Overrides the base URL path to proxy to.

    For example, the following builder code allows you to proxy all GET
    requests for .png paths to the lolcat image (yes, a silly example) but
    proxies to the internal host otherwise.

      my $mw = sub {
          my $app = shift;
          sub {
              my $env = shift;
              if ($env->{REQUEST_METHOD} eq 'GET' && $env->{PATH_INFO} =~ /\.png$/) {
                  $env->{'plack.proxy.url'} = 'http://lolcat.example.com/lol.png';
              }
              $app->($env);
          };
      };

      use Plack::Builder;

      builder {
          enable $mw;
          Plack::App::Proxy->new(remote => 'http://10.0.0.1:8080')->to_app;
      };

AUTHOR
    Lee Aylward

    Masahiro Honma

    Tatsuhiko Miyagawa

    Jesse Luehrs

LICENSE
    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

SEE ALSO
    Plack::Builder

plack-app-proxy's People

Contributors

doy avatar fcuny avatar hiratara avatar leedo avatar miyagawa avatar rbuels avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.