2 # Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
3 # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
5 # NewsWWW may be used independently of WWW. This can be useful
6 # for mapping HTTP/HTTPS requests to the hostname of an NNTP server
7 # to redirect users to the proper HTTP/HTTPS endpoint for a given
8 # inbox. NewsWWW exists because people (or software) can mishandle
9 # "nntp://" or "news://" URLs as "http://" (or "https://")
11 # Usage (development, with auto-reload):
12 # plackup -I lib -o 127.0.0.1 -R lib -r examples/newswww.psgi
14 # Usage (production, with public-inbox-httpd(1)):
15 # public-inbox-httpd [OPTIONS] /path/to/examples/newsww.psgi
20 use PublicInbox
::NewsWWW
;
22 my $newswww = PublicInbox
::NewsWWW
->new;
24 # Optional, (you may drop the "mount '/'" section below)
25 my $www = PublicInbox
::WWW
->new;
29 # HTTP/1.1 requests to "Host: news.example.com" will hit this:
30 mount
'http://news.example.com/' => builder
{
32 sub { $newswww->call($_[0]) };
35 # rest of requests will hit this (optional) part for the
36 # regular PublicInbox::WWW code:
37 # see comments in examples/public-inbox.psgi for more info:
38 mount
'/' => builder
{
39 eval { enable
'ReverseProxy' };
41 sub { $www->call($_[0]) }