Toadfarm::Manual::Intro - Introduction to Toadfarm
This manual aims to give an introduction to how to set up toadfarm.
toadfarm
First you need to create a basic script to describe when an application will be triggered. This is a plain Perl script which allow you to pull in any trick you like form the Perl toolbox.
Example:
#!/usr/bin/perl use Toadfarm -dsl; mount "/home/web/project1/script/app1" => { "X-Request-Base" => "http://mydomain.com/whatever" }; mount "Web::App2" => { "Host" => "mydomain.com", }; start;
The script above will pass the request on to app1 when the "X-Request-Base" header is set to "http://mydomain.com/whatever". Or it will pass the request on to Web::App2 if the "Host" header is set to "mydomain.com".
app1
Web::App2
You can save the content of the file anywhere and run it as any other Mojolicious application.
Note: There are other special fields to trigger on, besides HTTP headers. See "Apps" in Toadfarm::Manual::Config for more details.
After you have saved the config file, you can start the Toadfarm application:
$ /path/to/your-script start
After this, you should see your-script running and the applications can be accessed from http://localhost:8080.
your-script
See Toadfarm::Manual::RunningToadfarm for more command line options, and Toadfarm::Manual::Config for full list of config file options.
Setting up an iptables rules will allow Toadfarm to listen to port 8080, while still receiving traffic on the default port. This is a good idea security wise, since it will not require Toadfarm to be started as "root".
$ iptables -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 $ iptables -A PREROUTING -i eth0 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8443
Note: You need to replace "eth0" with the appropriate interface.
Toadfarm::Manual::Config.
Toadfarm::Manual::RunningToadfarm.
Jan Henning Thorsen - jhthorsen@cpan.org
jhthorsen@cpan.org
To install Toadfarm, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Toadfarm
CPAN shell
perl -MCPAN -e shell install Toadfarm
For more information on module installation, please visit the detailed CPAN module installation guide.