Apache 2 ports.conf modified automatically

0

I have an Ubuntu 16.04 server that has Apache 2 running on it. Apache 2 is supposed to be serving on port 443 only (and is currently working properly), but every half day or so /etc/apache2/ports.conf is edited from this:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

#Listen 80

<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<IfModule mod_ssl.c>
Listen 443
</IfModule>
#Listen 80

To the same thing but without Listen 80 commented out. This causes Apache 2 to try to serve on port 80 as well, but then it causes Apache 2 to crash completely due to port 80 being used by a different service.

My research seems to point me towards Let's Encrypt's certbot editing the file automatically, but I can't seem to find a way to stop it. (Let's Encrypt's certbot is installed on the system and is being used to automatically update the certificates). For the time being, I've disabled the certbot (or at least I think I have) with a sudo systemctl disable certbot, but the issues still persist (every half day or so the line is uncommented and Apache 2 crashes).

The only file in /etc/apache2/sites-enabled is 000-default-le-ssl.conf. This file does not seem to specify what to do with port 80.

I have also tried making ports.conf be just the following:

<IfModule mod_ssl.c>
Listen 443
</IfModule>

After restarting Apache 2, it works for about a half day and then the file is returned to the normal along with Apache 2 crashing.

I want to emphasize again that I am not 100% certain that it is certbot causing this; but from other articles online and from the frequency it seems likely.

Interestingly, this issue only started within the last few days. The server has been up for months and no edits have been made in the last two weeks (certbot has not been messed with for 2 months).

How can I stop Listen 80 from being in ports.conf?

pepperjack

Posted 2019-11-11T23:40:01.257

Reputation: 101

No answers