编辑了这个问题。我有这个简单的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;
};
使用简单的plackup
运行它。
当从本地机器访问:http://localhost:5000/some/path
时,它会打印:
Path info: /some/path
并获得了一个很好的Plack调试面板。
现在,我已将apache:80
配置如下:
ProxyPass /myapp/ http://127.0.0.1:5000/
ProxyPassReverse /myapp/ http://127.0.0.1:5000/
因此,所有请求的内容:http://SITE/myapp/
都代理上述Plack应用。因此,当尝试通过
http://SITE/myapp/some/path
浏览器再次正确打印:
Path info: /some/path
但是“Plack :: Middleware / Debug”不起作用,因为他将下一个URL发送到浏览器:
jquery.js -> /debug_toolbar/jquery.js
toolbar.min.js -> /debug_toolbar/toolbar.min.js
当然,它们并不存在。 (它们应该是/myapp/debug_toolbar/....
)
所以问题是:
somewhat
更改前缀为/myapp/
答案 0 :(得分:3)
更新:我想您只需要添加以下内容
enable "ReverseProxy"; ## Plack::Middleware::ReverseProxy
enable "ReverseProxyPath"; ## Plack::Middleware::ReverseProxyPath
更新:您可能还需要编辑apache httpd conf以将nocanon添加到proxypass ...
<强>下面* 是 *原始**响应强>
它没有硬编码,请亲自看看(我必须)
https://github.com/plack/Plack/wiki/How-to-detect-reverse-proxy-and-SSL-frontend http://p3rl.org/Plack::Middleware::ReverseProxy http://advent.plackperl.org/2009/12/day-12-maps-multiple-apps-with-mount-and-urlmap.html
#!/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 );