2 # Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
5 # Standalone HTTP server for public-inbox.
9 use PublicInbox::Daemon;
10 use PublicInbox::HTTP;
11 use PublicInbox::HTTPD;
17 eval { $app = Plack::Util::load_psgi(@ARGV) };
20 "$0 runs in /, command-line paths must be absolute\n";
23 require PublicInbox::WWW;
24 my $www = PublicInbox::WWW->new;
36 eval { enable 'ReverseProxy' };
38 "Plack::Middleware::ReverseProxy missing,\n",
39 "URL generation for redirects may be wrong if behind a reverse proxy\n";
42 sub { $www->call(@_) };
47 PublicInbox::Daemon::run('0.0.0.0:8080', $refresh,
48 sub ($$$) { # post_accept
49 my ($client, $addr, $srv) = @_;
50 my $fd = fileno($srv);
51 my $h = $httpds{$fd} ||= PublicInbox::HTTPD->new($srv, $app);
52 PublicInbox::HTTP->new($client, $addr, $h),