You do not even need to have a virtualhost with ssl enabled for certbot to work. You can have a simple VirtualHost responding to regular 80 port, then get the ssl certificate, then add the VirtualHost for SSL and all your modperl specifications to it. Something like the following, and once you got the certificate, you uncomment the 2nd part.

----
<Virtualhost *:80>
    ServerName api.example.org:80
    ServerAdmin w...@example.org
    DocumentRoot /var/www/api.example.org
    DirectoryIndex "index.html" "index.pl" "index.php"
    CustomLog "/var/log/apache2/api.example.org-access.log" combined
    ErrorLog "/var/log/apache2/api.example.org-error.log"
    LogLevel warn
    <Directory "/var/www/api.example.org">
        Options All +MultiViews -ExecCGI -Indexes -Includes
        AllowOverride All
    </Directory>
    ScriptAlias     "/cgi-bin/" "/var/www/api.example.org/cgi-bin/"
    <IfModule mod_alias.c>
        Alias "/icons/" "/var/www/icons/"
    </IfModule>
    <IfModule mod_ssl.c>
        RewriteEngine on
        RewriteRule ^\/?(.*)$ https://%{SERVER_NAME}/$1 [R,L]
    </IfModule>
</VirtualHost>

# <IfModule mod_ssl.c>
#     <VirtualHost *:443>
#         ServerName api.example.org:443
#         ServerAdmin w...@example.org
#         DocumentRoot /var/www/api.example.org
#         DirectoryIndex "index.html" "index.php"
#         CustomLog "/var/log/apache2/api.example.org-access.log" combined
#         ErrorLog "/var/log/apache2/api.example.org-error.log"
#         LogLevel warn
#         <Directory "/var/www/api.example.org">
#         RewriteEngine Off
#             Options All +MultiViews -ExecCGI -Indexes -Includes
#             AllowOverride All
#         </Directory>
#         ScriptAlias "/cgi-bin/" "/var/www/api.example.org/cgi-bin/"
#         <Directory "/var/www/api.example.org/cgi-bin/">
#             RewriteEngine Off
#             Options All +Includes +ExecCGI -Indexes +MultiViews
#             AllowOverride All
#             SetHandler cgi-script
#             AcceptPathInfo On
#             Require all granted
#         </Directory>
#         <IfModule mod_perl.c>
#             PerlOptions        +GlobalRequest
#             PerlPassEnv        MOD_PERL
#             PerlPassEnv        HOME
#             PerlPassEnv        SERVER_NAME
#             PerlPassEnv        HTTP_HOST
#             PerlPassEnv        REMOTE_ADDR
#             PerlPassEnv        REMOTE_HOST
#             PerlPassEnv        PATH_INFO
#             PerlPassEnv        LC_MESSAGES
#             PerlPassEnv        LANGUAGE
#             PerlModule        Apache2::Request
#             PerlModule        Apache2::Status
#             PerlModule        Apache::DBI
#             <Location />
#                 SetHandler        modperl
#                 PerlHandler        Apache::Registry
#                 PerlSendHeader      On
#                 PerlSetupEnv        On
#                 PerlOptions        +GlobalRequest
#                 Options            +Includes +ExecCGI
#                 Order allow,deny
#                 Allow from all
#             </Location>
#         </IfModule>
#
#         SSLCertificateFile /etc/ssl/private/api.example.org/cert.pem
#         SSLCertificateKeyFile /etc/ssl/private/api.example.org/privkey.pem
#         Include /etc/ssl/options-ssl-apache.conf
#
#         <IfModule mod_alias.c>
#             Alias "/icons/" "/var/www/icons/"
#         </IfModule>
#     </Virtualhost>
# </IfModule>
----


On 2022/07/03 19:00, Yong Walt wrote:
but that vhost has a modperl handler as the endpoint only.

On Sun, Jul 3, 2022 at 12:19 PM Mithun Bhattacharya <mit...@gmail.com> wrote:

    You don't enable SSL for a endpoint you do it for a host/port
    combination. All endpoints under that virtual host is SSL enabled.

    On Sat, Jul 2, 2022, 9:01 PM Yong Walt <yongw...@gmail.com> wrote:

        Hello

        When I run certbot --apache for modperl handler service, it
        doesn't work.
        So how can I setup letsencrypt SSL for a pure handler web API?

        Thanks


Attachment: OpenPGP_0x5F3C0261CDB2E752.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to