Skip to content
Browse files

Merge pull request #4 from kazeburo/master

Middleware::ReverseProxy
  • Loading branch information...
2 parents 5698b03 + 4bca3fe commit 2118291ac90ce2f8ff0ccc037117226cd9b9cb66 @yappo committed Jan 10, 2012
Showing with 16 additions and 1 deletion.
  1. +2 −0 Makefile.PL
  2. +10 −1 bin/ikachan
  3. +4 −0 lib/App/Ikachan.pm
View
2 Makefile.PL
@@ -5,6 +5,8 @@ readme_from 'lib/App/Ikachan.pm';
readme_markdown_from 'lib/App/Ikachan.pm';
githubmeta;
+requires 'Plack::Middleware::ReverseProxy';
+requires 'Plack::Builder::Conditionals';
requires 'AnySan' => '0.04';
requires 'Twiggy';
View
11 bin/ikachan
@@ -11,6 +11,7 @@ use AnySan::Provider::IRC;
use Getopt::Long ();
use Pod::Usage;
use Plack::Builder;
+use Plack::Builder::Conditionals;
use Plack::Request;
use Plack::Response;
use Twiggy::Server;
@@ -22,9 +23,11 @@ my $parser = Getopt::Long::Parser->new(
my %options;
my($http_host, $http_port, $irc_server, $irc_port, $irc_keyword, $irc_nickname, $no_post_with_join, $irc_post_interval) =
('127.0.0.1', 4979, undef, 6667, undef, 'ikachan', 0, 2);
+my @reverse_proxy;
$parser->getoptions(
'o|host=s' => \$http_host,
'p|port=i' => \$http_port,
+ 'r|reverse-proxy=s' => \@reverse_proxy,
'S|Server=s' => \$irc_server,
'P|Port=i' => \$irc_port,
'K|Keyword=s' => \$irc_keyword,
@@ -190,8 +193,10 @@ HTML
return rendar(404, 'not found');
};
-
my $app = builder {
+ if ( @reverse_proxy ) {
+ enable match_if addr(\@reverse_proxy), 'Plack::Middleware::ReverseProxy';
+ }
enable 'Plack::Middleware::AccessLog', format => 'combined';
$code;
};
@@ -241,6 +246,10 @@ irc server address.
irc server port.
+=item -r, --reverse-proxy
+
+treat X-Forwarded-For as REMOTE_ADDR if REMOTE_ADDR match this argument
+
=item -K, --Keyword
=item -N, --Nickname
View
4 lib/App/Ikachan.pm
@@ -40,6 +40,10 @@ irc server address.
irc server port.
+=item -r, --reverse-proxy
+
+treat X-Forwarded-For as REMOTE_ADDR if REMOTE_ADDR match this argument
+
=item -K, --Keyword
=item -N, --Nickname

0 comments on commit 2118291

Please sign in to comment.
Something went wrong with that request. Please try again.