2012/10/30

plack を使ってて「サーバのサブフォルダを間借りして動かしたい」って事がたまにあるんだけど、そんな場合 nginx の設定でリバースプロキシに渡すって事をやります。 location /foo {
    try_files $uri $uri.html $uri/index.html @proxy-foo;
}

location @proxy-foo {
    proxy_pass http://localhost:5000;
    proxy_set_header Host $http_host;
}
この場合、通常の Plack アプリケーションだと / がアプリケーションルートになっているので404になってしまう。よって app.psgi とは別に !perl

use strict;
use warnings;
use Plack::Builder;
use Plack::Util;

builder {
    mount '/foo/' => Plack::Util::load_psgi('app.psgi');
}
の様な wrapper スクリプトを書く必要がありました。
しかし先日、plackup に --path 引数が追加され $ plackup --path /foo と書くことで、自動的にマウントしてくれる機能が付きました。
これでいちいち wrapper スクリプトを書かずに済むようになりました。

僕的に便利
Posted at 12:45 | WriteBacks () | Edit
Edit this entry...

wikieditish message: Ready to edit this entry.






















A quick preview will be rendered here when you click "Preview" button.