Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 将Plack应用程序与反向代理一起使用-Plack::Middleware::Debug_Perl_Plack - Fatal编程技术网

Perl 将Plack应用程序与反向代理一起使用-Plack::Middleware::Debug

Perl 将Plack应用程序与反向代理一起使用-Plack::Middleware::Debug,perl,plack,Perl,Plack,编辑了这个问题。我有一个简单的Plackapp.psgi: my $app = sub { my $env = shift; return [ 200, ['Content-Type' => 'text/html'], [ "<html><head><title>x</title></head><body><pre>Path info: $en

编辑了这个问题。我有一个简单的Plack
app.psgi

my $app = sub {
    my $env = shift;
    return [
        200,
        ['Content-Type' => 'text/html'],
        [ "<html><head><title>x</title></head><body><pre>Path info: $env->{PATH_INFO}</pre></body></html>"],
    ];
};

use Plack::Builder;
builder {
    enable 'Debug';
    $app;
};
因此,所有请求的结果是:
http://SITE/myapp/
是上述Plack应用程序的代理。所以,当尝试通过

Path info: /some/path
浏览器再次正确地打印:

jquery.js -> /debug_toolbar/jquery.js
toolbar.min.js -> /debug_toolbar/toolbar.min.js
但是“Plack::Middleware/Debug”不起作用,因为他将下一个URL发送到浏览器:

enable "ReverseProxy";     ##  Plack::Middleware::ReverseProxy 
enable "ReverseProxyPath"; ##  Plack::Middleware::ReverseProxyPath 
当然,它们并不存在。(它们应该是
/myapp/debug\u toolbar/…

因此,问题是:

  • 我需要做什么-如何更改上面的app.psgi以获得可用的应用程序
  • 我需要用前缀
    /myapp/

更新:我想您所需要的只是添加以下内容

#!/usr/bin/perl --
#~ plack-debug-mounted.pl
#~ 2013-10-17-02:59:26
#~ 
## perltidy -olq  -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr -ce -nibc -i=4 -pt=0   "-nsak=*"
#!/usr/bin/perl --
use CGI();
use Data::Dump qw/ dd pp /;
use Path::Tiny qw/ path /;
use Plack::Builder;
use Plack::Runner;

my $selfsourceapp = sub {
    return [
        '200',
        [ 'Content-Type' => 'text/plain', ],
        [ path( __FILE__ )->slurp_raw ],
    ];
};
my $dumperapp = sub {
    my $q = CGI->new( $_[0] );
    return [
        '200', [
            'Content-Type'   => 'text/html',
            'Content-Length' => '2',
        ], [
            $q->start_html( -title => 'dumpenv.psgi' ),
            $q->h1( $_[0]->{SCRIPT_NAME} ),
            $q->Dump, $q->end_html,
        ],
    ];
};

my $indexapp = sub {
    return [
        '200',
        [ 'Content-Type' => 'text/html', ],
        [
            q{<doctype html>
<html lang="en-US" charset="UTF-8">
<title> Plack perlology </title>
<body>
<p> A Plack::Middleware::Debug free zone
<br> <a href="/"> this </a>
<br> <a href="/dumpenv"> dupenv </a>
<br> <a href="/selfsrc"> selfsrc </a>
<p> Get <c>Plack::Middleware::Debug</c> <b> ed </b>
<br> <a href="/debugged/"> /debugged/ this </a>
<br> <a href="/debugged/dumpenv"> /debugged/dupenv </a>
<br> <a href="/debugged/selfsrc"> /debugged/selfsrc </a>
<p> Come get some
<br> <a href="/debugged/debug_toolbar/toolbar.min.css">
/debugged/debug_toolbar/toolbar.min.css
</a>
<br> <a href="/debugged/debug_toolbar/toolbar.min.js">
/debugged/debug_toolbar/toolbar.min.js
</a>
<p> Cant get this
<br> <a href="/debug_toolbar/toolbar.min.css">
/debug_toolbar/toolbar.min.css
</a>
<br> <a href="/toolbar.min.css">
/toolbar.min.css
</a>

</body><!-- before this Plack::Middleware::Debug inserts, viewsource!! -->
}
        ],
    ];
};

my $finalapp = builder {
    mount '/debugged' => builder {
        enable 'Debug', panels => [
            qw/
              Timer
              Response
              Environment
              Session
              Parameters
              /
        ];
        mount "/dumpenv" => $dumperapp;
        mount "/selfsrc" => $selfsourceapp;
        mount "/"        => $indexapp;
    };

    mount "/dumpenv" => $dumperapp;
    mount "/selfsrc" => $selfsourceapp;
    mount "/"        => $indexapp;
};

my $runner = Plack::Runner->new;
$runner->parse_options( qw' --host 127.0.0.1 --port 80 ' );
$runner->run( $finalapp );
更新:您可能还需要编辑apache httpd conf以将nocanon添加到proxypass中

以下*为*原始**响应

它不是硬编码的,请自己查看(我必须

#/usr/bin/perl--
#~plack-debug-mounted.pl
#~ 2013-10-17-02:59:26
#~ 
##perltidy-olq-csc-csci=10-cscl=“sub:BEGIN-END if”-otr-opr-ce-nibc-i=4-pt=0”-nsak=*”
#!/usr/bin/perl--
使用CGI();
使用数据::转储qw/dd pp/;
使用路径::Tiny qw/Path/;
使用Plack::Builder;
使用Plack::Runner;
我的$selfsourceapp=sub{
返回[
'200',
['内容类型'=>'文本/普通',],
[路径(_文件)->slurp\u原始],
];
};
我的$dumperapp=sub{
我的$q=CGI->new($\u0]);
返回[
'200', [
'内容类型'=>'文本/html',
“内容长度”=>“2”,
], [
$q->start_html(-title=>'dumpenv.psgi'),
$q->h1($\u0]->{SCRIPT\u NAME}),
$q->Dump,$q->end\u html,
],
];
};
我的$indexapp=sub{
返回[
'200',
['内容类型'=>'文本/html',],
[
q{
普莱克心理学
Plack::Middleware::调试自由区



获取Plack::中间件::调试


来拿些

我拿不到这个

} ], ]; }; 我的$finalapp=builder{ 装载'/debuged'=>builder{ 启用“调试”,面板=>[ 量子阱/ 计时器 回应 环境 一场 参数 / ]; mount“/dumpenv”=>$dumperapp; mount“/selfsrc”=>$selfsourceapp; mount“/”=>$indexapp; }; mount“/dumpenv”=>$dumperapp; mount“/selfsrc”=>$selfsourceapp; mount“/”=>$indexapp; }; my$runner=Plack::runner->new; $runner->parse_选项(qw'--host 127.0.0.1--port 80'); $runner->run($finalapp);
更新:我想您只需要添加以下内容

#!/usr/bin/perl --
#~ plack-debug-mounted.pl
#~ 2013-10-17-02:59:26
#~ 
## perltidy -olq  -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr -ce -nibc -i=4 -pt=0   "-nsak=*"
#!/usr/bin/perl --
use CGI();
use Data::Dump qw/ dd pp /;
use Path::Tiny qw/ path /;
use Plack::Builder;
use Plack::Runner;

my $selfsourceapp = sub {
    return [
        '200',
        [ 'Content-Type' => 'text/plain', ],
        [ path( __FILE__ )->slurp_raw ],
    ];
};
my $dumperapp = sub {
    my $q = CGI->new( $_[0] );
    return [
        '200', [
            'Content-Type'   => 'text/html',
            'Content-Length' => '2',
        ], [
            $q->start_html( -title => 'dumpenv.psgi' ),
            $q->h1( $_[0]->{SCRIPT_NAME} ),
            $q->Dump, $q->end_html,
        ],
    ];
};

my $indexapp = sub {
    return [
        '200',
        [ 'Content-Type' => 'text/html', ],
        [
            q{<doctype html>
<html lang="en-US" charset="UTF-8">
<title> Plack perlology </title>
<body>
<p> A Plack::Middleware::Debug free zone
<br> <a href="/"> this </a>
<br> <a href="/dumpenv"> dupenv </a>
<br> <a href="/selfsrc"> selfsrc </a>
<p> Get <c>Plack::Middleware::Debug</c> <b> ed </b>
<br> <a href="/debugged/"> /debugged/ this </a>
<br> <a href="/debugged/dumpenv"> /debugged/dupenv </a>
<br> <a href="/debugged/selfsrc"> /debugged/selfsrc </a>
<p> Come get some
<br> <a href="/debugged/debug_toolbar/toolbar.min.css">
/debugged/debug_toolbar/toolbar.min.css
</a>
<br> <a href="/debugged/debug_toolbar/toolbar.min.js">
/debugged/debug_toolbar/toolbar.min.js
</a>
<p> Cant get this
<br> <a href="/debug_toolbar/toolbar.min.css">
/debug_toolbar/toolbar.min.css
</a>
<br> <a href="/toolbar.min.css">
/toolbar.min.css
</a>

</body><!-- before this Plack::Middleware::Debug inserts, viewsource!! -->
}
        ],
    ];
};

my $finalapp = builder {
    mount '/debugged' => builder {
        enable 'Debug', panels => [
            qw/
              Timer
              Response
              Environment
              Session
              Parameters
              /
        ];
        mount "/dumpenv" => $dumperapp;
        mount "/selfsrc" => $selfsourceapp;
        mount "/"        => $indexapp;
    };

    mount "/dumpenv" => $dumperapp;
    mount "/selfsrc" => $selfsourceapp;
    mount "/"        => $indexapp;
};

my $runner = Plack::Runner->new;
$runner->parse_options( qw' --host 127.0.0.1 --port 80 ' );
$runner->run( $finalapp );
更新:您可能还需要编辑apache httpd conf以将nocanon添加到proxypass中

以下*为*原始**响应

它不是硬编码的,请自己查看(我必须

#/usr/bin/perl--
#~plack-debug-mounted.pl
#~ 2013-10-17-02:59:26
#~ 
##perltidy-olq-csc-csci=10-cscl=“sub:BEGIN-END if”-otr-opr-ce-nibc-i=4-pt=0”-nsak=*”
#!/usr/bin/perl--
使用CGI();
使用数据::转储qw/dd pp/;
使用路径::Tiny qw/Path/;
使用Plack::Builder;
使用Plack::Runner;
我的$selfsourceapp=sub{
返回[
'200',
['内容类型'=>'文本/普通',],
[路径(_文件)->slurp\u原始],
];
};
我的$dumperapp=sub{
我的$q=CGI->new($\u0]);
返回[
'200', [
'内容类型'=>'文本/html',
“内容长度”=>“2”,
], [
$q->start_html(-title=>'dumpenv.psgi'),
$q->h1($\u0]->{SCRIPT\u NAME}),
$q->Dump,$q->end\u html,
],
];
};
我的$indexapp=sub{
返回[
'200',
['内容类型'=>'文本/html',],
[
q{
普莱克心理学
Plack::Middleware::调试自由区



获取Plack::中间件::调试


来拿些

我拿不到这个

} ], ]; }; 我的$finalapp=builder{ 装载'/debuged'=>builder{ 启用“调试”,面板=>[ 量子阱/ 计时器 回应 环境 一场 参数 / ]; mount“/dumpenv”=>$dumperapp; mount“/selfsrc”=>$selfsourceapp; mount“/”=>$indexapp; }; mount“/dumpenv”=>$dumperapp; mount“/selfsrc”=>$selfsourceapp; mount“/”=>$indexapp; }; my$runner=Plack::runner->new; $runner->parse_选项(qw'--host 127.0.0.1--port 80'); $runner->run($finalapp);
我在这里找到了一些东西:
Plack-Middleware-Debug-0.16/lib/Plack/Middleware/Debug.pm
…var jquery\u url='{BASE\u url}%>/Debug\u toolbar/jquery.js'。。。你试图修改这里的路径了吗?把问题编辑得更容易理解-至少我希望…我在这里找到了一些东西:
Plack-Middleware-Debug-0.16/lib/Plack/Middleware/Debug.pm
…var jquery\u url='{BASE\u url}%>/Debug\u toolbar/jquery.js'。。。您是否尝试修改此处的路径?编辑问题以使其更易于理解-至少我希望…我编辑了我的问题。你能帮助我在我的
app.pasi
中更改什么以获得一个可用的应用程序吗?我已更新;)尝试启用ReverseProxy路径ReverseProxy并查看它是否工作它工作-接受。但仍然在寻找“如何在反向代理后编写最佳Plack应用程序”的“好指南”:)我编辑了我的问题。你能帮助我在我的
app.pasi
中更改什么以获得一个可用的应用程序吗?我已更新;)尝试启用ReverseProxy路径ReverseProxy并查看它是否工作它工作-接受。但是
#!/usr/bin/perl --
#~ plack-debug-mounted.pl
#~ 2013-10-17-02:59:26
#~ 
## perltidy -olq  -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr -ce -nibc -i=4 -pt=0   "-nsak=*"
#!/usr/bin/perl --
use CGI();
use Data::Dump qw/ dd pp /;
use Path::Tiny qw/ path /;
use Plack::Builder;
use Plack::Runner;

my $selfsourceapp = sub {
    return [
        '200',
        [ 'Content-Type' => 'text/plain', ],
        [ path( __FILE__ )->slurp_raw ],
    ];
};
my $dumperapp = sub {
    my $q = CGI->new( $_[0] );
    return [
        '200', [
            'Content-Type'   => 'text/html',
            'Content-Length' => '2',
        ], [
            $q->start_html( -title => 'dumpenv.psgi' ),
            $q->h1( $_[0]->{SCRIPT_NAME} ),
            $q->Dump, $q->end_html,
        ],
    ];
};

my $indexapp = sub {
    return [
        '200',
        [ 'Content-Type' => 'text/html', ],
        [
            q{<doctype html>
<html lang="en-US" charset="UTF-8">
<title> Plack perlology </title>
<body>
<p> A Plack::Middleware::Debug free zone
<br> <a href="/"> this </a>
<br> <a href="/dumpenv"> dupenv </a>
<br> <a href="/selfsrc"> selfsrc </a>
<p> Get <c>Plack::Middleware::Debug</c> <b> ed </b>
<br> <a href="/debugged/"> /debugged/ this </a>
<br> <a href="/debugged/dumpenv"> /debugged/dupenv </a>
<br> <a href="/debugged/selfsrc"> /debugged/selfsrc </a>
<p> Come get some
<br> <a href="/debugged/debug_toolbar/toolbar.min.css">
/debugged/debug_toolbar/toolbar.min.css
</a>
<br> <a href="/debugged/debug_toolbar/toolbar.min.js">
/debugged/debug_toolbar/toolbar.min.js
</a>
<p> Cant get this
<br> <a href="/debug_toolbar/toolbar.min.css">
/debug_toolbar/toolbar.min.css
</a>
<br> <a href="/toolbar.min.css">
/toolbar.min.css
</a>

</body><!-- before this Plack::Middleware::Debug inserts, viewsource!! -->
}
        ],
    ];
};

my $finalapp = builder {
    mount '/debugged' => builder {
        enable 'Debug', panels => [
            qw/
              Timer
              Response
              Environment
              Session
              Parameters
              /
        ];
        mount "/dumpenv" => $dumperapp;
        mount "/selfsrc" => $selfsourceapp;
        mount "/"        => $indexapp;
    };

    mount "/dumpenv" => $dumperapp;
    mount "/selfsrc" => $selfsourceapp;
    mount "/"        => $indexapp;
};

my $runner = Plack::Runner->new;
$runner->parse_options( qw' --host 127.0.0.1 --port 80 ' );
$runner->run( $finalapp );