Toadfarm::Manual::BehindReverseProxy - Toadfarm behind nginx
This is useful when you want to run Toadfarm behind a reverse proxy, such as nginx.
nginx
The "rewrite" rule is very important, since it will remove the "/myapp" part from the request URL that the Mojolicious route dispatcher will see.
upstream myapp { server 10.11.12.13:8001; } server { listen 80; server_name domain.com location /myapp { rewrite ^/myapp/?(.*)$ /$1 break; proxy_set_header X-Request-Base http://$host/myapp; proxy_pass http://myapp; } }
The magic part here is the "X-Request-Base" HTTP header which is set by nginx.
{ apps => [ '/home/www/project1/script/app1' => { 'X-Request-Base' => 'http://domain.com/myapp', }, ], hypnotoad => { workers => 8, pid_file => '/tmp/toadfarm.pid', listen => [ "http://*:8080" ], }, };
http://wiki.nginx.org/HttpProxyModule
http://wiki.nginx.org/HttpUpstreamModule
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.