try
feature.try
feature.What was available to me:
root
!root
to install development packages for C
dependencies.In most cases, already included in the service.
From the moment my domain was registered, the server began to be bombarded by various requests (HTTP, SSH).
sshd
on a non-standard port.sshd_config
:
PermitRootLogin no
I’ll use the application I run on my server as an example. It lists my Perl talks with slides (and can show the graph we saw in the previous slide).
. ├── cpanfile ├── lib │ ├── BanGraph.pm │ ├── MyTemplate.pm │ ├── NoTrailingSlash.pm │ └── Talks.pm ├── app.pl └── talks.in
# from the Synopsis use Plack::Builder; builder { enable 'Static', path => qr{^/(images|js|css)/}, root => './htdocs/'; $app };
#! /usr/bin/perl use warnings; use strict; use Plack::Builder; use FindBin; use lib './lib'; use Talks; use BanGraph; use NoTrailingSlash; use MyTemplate; my $root = $FindBin::Bin; my $app = sub { my $env = shift; my $status = 200; my $headers = ['Content-type' => 'text/html']; my $body = [ MyTemplate::page(title => 'E. Choroba', h1 => 'My Talks', li => [Talks::talks($root)]) ]; return [ $status, $headers, $body ] }; builder { my $dirs_re = Talks::dirs_re($root); enable sub { NoTrailingSlash::add_index(shift, $dirs_re) }; enable 'Static', path => sub { s{^/($dirs_re)/$}{$1/index.html} }, root => $root; enable 'Static', path => qr{^/$dirs_re/.}, root => $root; mount '/ban.png' => sub { BanGraph::png($root) }; mount '/' => $app; };
Unfortunately, this doesn’t work:
enable 'Static', path => sub { s{^/($dirs_re)/$}{$1/index.html} }, root => $root;
Unfortunately, this doesn’t work:
enable 'Static', # ↓ # path => sub { s{^/($dirs_re)/?$}{$1/index.html} }, root => $root;
It breaks relative links.
package NoTrailingSlash; use Plack::Request; sub add_index { my ($app, $dirs_re) = @_; sub { my ($env) = @_; my $req = 'Plack::Request'->new($env); my $path = $req->path; return [ 301, [ Location => "$1/index.html" ], [] ] if $path =~ m{^/($dirs_re)$}; my $res = $app->($env); $res } } __PACKAGE__
le.pl --key account.key \ --email name@example.com \ --csr domain.csr \ --csr-key domain.key \ --crt domain.crt \ --generate-missing \ --domains 'example.com'
starman --port 5000 \ --access-log access.log \ --ssl-key domain.key \ --ssl-cert domain.crt \ --enable-ssl \ app.pl &> https.log
To run an application on a virtual server, you need
Conference in the Cloud | 2021 |