Skip to content

Instantly share code, notes, and snippets.

Created July 31, 2012 23:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/42c32258713b34f3604e to your computer and use it in GitHub Desktop.
Save anonymous/42c32258713b34f3604e to your computer and use it in GitHub Desktop.
use Mojo::UserAgent;
use Mojo::Server::Daemon;
my $ua = Mojo::UserAgent->new();
my $daemon = Mojo::Server::Daemon->new(listen => ['https://*:443'])->unsubscribe('request');
$daemon->on(request => sub {
my ($daemon, $tx) =@_;
my $req = $tx->req->clone();
$req->url->scheme("https")->host("10.3.199.40");
$ua->start(Mojo::Transaction::HTTP->new(req => $req) => sub {
my ($ua, $proxy_tx) = @_;
$tx->res($proxy_tx->res)->resume();
});
});
$daemon->run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment