App-Phoebe
view release on metacpan or search on metacpan
script/phoebe view on Meta::CPAN
(the default is to just serve C<localhost>).
phoebe --host=127.0.0.1 --host=localhost
Visit both at L<gemini://localhost/> and L<gemini://127.0.0.1/>, and create a
new page in each one, then examine the data directory F<wiki>. You'll see both
F<wiki/localhost> and F<wiki/127.0.0.1>.
If you're using more wiki spaces, you need to prefix them with the respective
hostname if you use more than one:
phoebe --host=127.0.0.1 --host=localhost \
--wiki_space=127.0.0.1/alex --wiki_space=localhost/berta
In this situation, you can visit L<gemini://127.0.0.1/>,
L<gemini://127.0.0.1/alex/>, L<gemini://localhost/>, and
L<gemini://localhost/berta/>, and they will all be different.
If this is confusing, remember that not using virtual hosting and not using
spaces is fine, too. ð
=head2 Multiple Certificates
If you're using virtual hosting as discussed above, you have two options: you
can use one certificate for all your hostnames, or you can use different
certificates for the hosts. If you want to use just one certificate for all your
hosts, you don't need to do anything else. If you want to use different
certificates for different hosts, you have to specify them all on the command
line. Generally speaking, use C<--host> to specifiy one or more hosts, followed
by both C<--cert_file> and C<--key_file> to specifiy the certificate and key to
use for the hosts.
For example:
phoebe --host=transjovian.org \
--cert_file=/home/alex/phoebe/transjovian-cert.pem \
--key_file=/home/alex/phoebe/transjovian-key.pem \
--host=alexschroeder.ch \
--cert_file=/home/alex/phoebe/alexschroeder-cert.pem \
--key_file=/home/alex/phoebe/alexschroeder-key.pem
=head1 SEE ALSO
The Transjovian Council has a wiki space dedicated to Phoebe, and it includes a
section with more configuration examples. See L<gemini://transjovian.org/phoebe>
or L<https://transjovian.org:1965/phoebe>.
=head1 LICENSE
GNU Affero General Public License
=cut
use FindBin;
use lib "$FindBin::Bin/../lib";
use App::Phoebe qw($log $server host_regex handle_request get_ip_numbers);
use Modern::Perl '2018';
use File::Slurper qw(read_dir);
use Encode qw(decode);
use Encode::Locale;
use IO::Socket::SSL;
use Mojo::IOLoop;
use Getopt::Long;
use Pod::Text;
use utf8;
use B;
# Some of these need to be decoded (hostnames, pagenames).
GetOptions(
$server,
'help' => \&help,
'log_level=s' => sub { $log->level($_[1]), },
'log_file=s' => sub { $log->path($_[1]) },
'no_cert' => \&host_setup,
'cert_file=s' => \&host_setup,
'key_file=s' => \&host_setup,
'host=s@' => \&host_setup,
'port=i@' => \&host_setup,
'wiki_dir=s',
'wiki_space=s@' => \&utf8_list_item,
'wiki_token=s@' => \&utf8_list_item,
'wiki_page=s@' => \&utf8_list_item,
'wiki_main_page=s' => \&utf8_item,
'wiki_mime_type=s@',
'wiki_page_size_limit=i')
or die("Error in command line arguments\n");
sub utf8_list_item { my ($key, $value) = @_; push(@{$server->{$key}}, decode(locale => $value)) };
sub utf8_item { my ($key, $value) = @_; $server->{$key} = decode(locale => $value) };
{
# use a block so that these variables stay local
my ($cert_file, $key_file, @host, @port);
sub host_setup {
my ($opt, $val) = @_;
if ($opt eq 'host') {
push @host, map { decode(locale => $_) } $val;
return;
} elsif ($opt eq 'port') {
push @port, $val;
return;
} elsif ($opt eq 'no_cert') {
push @port, 1965 unless @port;
if (not @host and not $server->{host}->{'localhost'}) {
$server->{host}->{'localhost'} = 1;
$server->{port}->{'localhost'} = [@port];
}
for my $host (@host) {
$server->{host}->{$host} = 1;
push(@{$server->{port}->{$host}}, @port);
# no $server->{cert_file} and $server->{key_file}
}
@host = @port = ();
return;
}
die "$val does not exist\n" unless -f $val;
if ($opt eq 'cert_file') { $cert_file = $val }
elsif ($opt eq 'key_file') { $key_file = $val }
if ($cert_file and $key_file) {
push @port, 1965 unless @port;
( run in 1.564 second using v1.01-cache-2.11-cpan-39bf76dae61 )