[Perl][Dancer][Apache][Ubuntu12.04LTS]Dancerをリバースプロキシ経由で動かす場合の設定方法

Perlの軽量WebフレームワークDancerを導入してみたときにハマったのでまとめてみました。 参考URL

Contents

Dancerのインストール

普通にCPANからインストールします。
$ perl -MCPAN -e shell
cpan> install Dancer
cpan> quit

Hello Worldを書く

bin/app.pl

#!/usr/bin/env perl
use Dancer ':syntax';
#use sharss;

get '/' => sub {
   'Hello, World!';
};

dance;

app.psgi

require 'bin/app.pl';

テスト実行

まず実行する。
perl app.psgi
次に、http://localhost:3000/にアクセスして”Hello, World!”と表示されていればOK!

リバースプロキシの設定

mod_proxyのインストール

sudo apt-get install libapache2-mod-proxy-html
sudo apt-get install libxml2-dev

confファイルの設定

<Location "/test">
    RequestHeader set request-base /var/www/something
    ProxyPass http://localhost:3000
    ProxyPassReverse http://localhost:3000
</Location>
ここのProxyPassとProxyPassReverseの最後に”/”を入れているとうまく動かないようです。
それで少しハマりましたorz

mod_proxyの有効化

sudo a2enmod proxy
sudo a2enmod proxy_http headers
sudo /etc/init.d/apache2 restart

テスト

http://localhost/testでアクセスして”Hello, World!”と表示されればOK! [[amazon2][4873115671][4844328654]]I was annoyed something when I introduction of light Web framework Dancer for Perl.
This article is the memo about that. References:
zuqqhi2

某Web系の会社でエンジニアをやっています。 学術的なことに非常に興味があります。 趣味は楽器演奏、ジョギング、読書、料理などなど手広くやっています。