Categories: Uncategorized

[Perl][Dancer][Apache][Ubuntu12.04LTS]How to set apache to run Dancer via reverse proxy

Install Dancer

$ 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';

Test

Run.
perl app.psgi
“Hello, World!” will be shown when you access http://localhost:3000/.

Setting reverse proxy

install mod_proxy module

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

Setting conf file

<Location "/test">
    RequestHeader set request-base /var/www/something
    ProxyPass http://localhost:3000
    ProxyPassReverse http://localhost:3000
</Location>
If you add “/” the end of ProxyPass and ProxyPass Reverse, the reverse proxy maybe don’t work.
I stacked a little bit about it.

validation of mod_proxy

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

Test

“Hello, World!” will be shown when you access http://localhost/test. That’s all. [[amazon2][4873115671][4844328654]]
zuqqhi2