Unable to renew cert

I'm having the same issue, but using apache. Certbot gets a 404 error when trying to load the acme-challenge. Certbot worked before and I haven't changed the apache configuration, but I'm going to check through it.

1 Like

I was able to get my renewal to work by specifying where my document root was with this parameter:
--webroot -w /var/www/html

1 Like

Hi @Addy771, welcome to the LE community forum :slight_smile:

Although I am glad you were able to circumvent the problem and get a new cert issued, the problem is likely still there and should be corrected.
If you would like to go down that road, please show the output of:
sudo apachectl -t -D DUMP_VHOSTS

1 Like

Thanks @rg305! I am indeed interested in what the root cause of this problem is.

The output of sudo apachectl -y -D DUMP_VHOSTS:

[Mon Sep 20 15:32:17.374292 2021] [core:error] [pid 13405] (EAI 2)Name or service not known: AH00547: Could not resolve host name doc.chtech.us.to -- ignoring!
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
24.84.228.171:80 S0106749be8129543.vc.shawcable.net (/etc/apache2/sites-enabled/cht-server.conf:6)
*:443 chtech.us.to (/etc/apache2/sites-enabled/cht-server-le-ssl.conf:2)

I hadn't noticed that ServerName was missing.

2 Likes

You can basically ignore this (warning):

This one is a bit more severe:

[if you are trying to serve that FQDN]

So, which is the FQDN that you are having trouble with?
chtech.us.to ?

1 Like

doc.chtech.us.to was left in by mistake, I've removed it now. chtech.us.to is what I was having trouble with.

1 Like

OK, chtech.us.to lacks a vhost config for port 80.
Did you disable it? or delete it?

We should have a look at file:
/etc/apache2/sites-enabled/cht-server.conf

1 Like

cht-server.conf:

<VirtualHost chtech.us.to:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

        # Redirect to HTTPS
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =chtech.us.to
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Now when I do a dry run without specifying the web root, it's successful

adam@CHT-server:~$ sudo certbot renew --dry-run
[sudo] password for adam: 
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/chtech.us.to.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for chtech.us.to

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded: 
  /etc/letsencrypt/live/chtech.us.to/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

It doesn't seem like the problem exists anymore.

That vhost config lacks a ServerName.

Thanks, I fixed that.

1 Like

OK, so is everything good now?

Yes, other than my HTTPS redirect not working.

At first I had

RewriteEngine on
RewriteCond %{SERVER_NAME} =chtech.us.to
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

I also tried

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

as well as

Redirect / https://chtech.us.to/

But none of these seem to work. The rewrite module is enabled, not sure what's going on.

I dare say Apache is going on!

Let's (re)review the output of:
sudo apachectl -t -D DUMP_VHOSTS

VirtualHost configuration:
24.84.228.171:80       chtech.us.to (/etc/apache2/sites-enabled/cht-server.conf:3)
*:443                  chtech.us.to (/etc/apache2/sites-enabled/cht-server-le-ssl.conf:2)

I changed the vhost to *:80 instead of chtech.us.to:80 and now the redirect is working. Thanks again for your guidance!

1 Like

So if now all is good, then I'm glad to have helped you get there :slight_smile:
Cheers from Miami :beers:

#FreeCUBA :cuba:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.