Contents of apache httpd.conf file empty - how to restore?

I was making some changes, clicked on save but it hanged, then on going back to the page (Servers > Apache Webserver > global configuration) it is empty:

(Side note: I’m pretty sure there were other files that would usually show in the drop down too, such as SSL config etc - but they all seem to have disappeared. Also at Servers > Apache Webserver there are no domains listed - pretty sure there is usually a list of domains there.)

Is there any way to restore/locate these files? Are they in memory anywhere? (Sites seem to be working atm - though I expect they will stop once httpd or the server is restarted.)

I had Virtualmin set to backup virtualmin settings, but there does not appear to be any Apache files in the virtualmin.tar.gz that was saved/backed-up:

This is what I had the settings as:

(Backup all features was checked)

What is the process to restore the Apache config from the backup? Is the Apache config even there? (I hope so!)

Virtualmin settings are literally Virtualmin settings, not any of the services Virtualmin manages. Apache is not Virtualmin.

Apache configuration for the virtual server (i.e. just the VirtualHost section) will be in the backup, since you chose “Backup all features”.

But, that’s not your http.conf, at least not all of it. If you have etckeeper installed and configured, you can roll back. If you have config file backups (which could be setup in Webmin->Webmin->Backup Configuration Files), you could restore the whole file from those backups. If you have a full system backup, you could restore the file from that.

If you don’t have any form of backup that actually contains that file, you can mostly recreate it by reinstalling the default packaged config file for the httpd package. First copy the empty one out of the way (because config files are not replaced by packages on upgrades or reinstalls in the general case), and then run dnf reinstall httpd. And, then, after you have a default config, you’ll need to do virtualmin config-system Apache and then restore the Apache website feature for all domains on the system (but only that feature). At least, I think that’ll work. Maybe test on a devel system.

That said, I think there would be a tmp file somewhere for that file that was being edited that you can probably restore it (the way any file editing in Webmin works involves creating a new temporary file and then copying it over the file being changed so that there’s less opportunity for this sort of thing to happen in the event of something like a system crash or network failure or whatever during an operation). I don’t know where the editor stores tmp files, thuogh…it’s not apparent to me in a quick search. Maybe just in the /tmp/.webmin dir somewhere. I’d look around for something with httpd.conf in the name in there and maybe in /var/webmin.

1 Like

First do as Joe suggests.

If you have no luck with that, disable the virtual server, say a small prayer and then enable it again.

1 Like

That can’t do anything useful. If the httpd.conf is completely gone, there’s nothing to even add a VirtualHost to. I’m not even sure what would happen. Best case it would add the VirtualHost section to the empty file, and you’d still have an invalid httpd.conf. Virtualmin cannot invent a whole Apache configuration file out of nothing. We don’t generate files from templates…we edit files in place. That’s a feature, not a bug, but it assumes the config file isn’t deleted out from under it. (I’m alarmed that editing the file in Webmin could lead to it being emptied out. My reading of the code doesn’t provide an obvious path for that to happen, and it hasn’t happened very often that I’m aware of. But, I’m still uncomfortable with it.)

1 Like

Me too Joe. The only thing I can think of is that I have Apple’s iCloud Private Relay switched on in Safari - which is like a proxy of sorts, where your IP address is hidden from websites. I think I might have also pressed save twice by accident, but again, not sure why that would cause an issue.

I couldn’t find it so in the end I commissioned a new server and restored from old backups.

I didn’t realise there was a separate webmin backup - I thought the virtualmin backup of all settings covered everything. I will set up a webmin back up as well now moving forward.

I know it’s in the Webmin menu, but it’s not a Webmin backup. It’s system configuration files for the modules Webmin manages. You could do the same by backing up all of /etc every day or whatever. (etckeeper checks everything in /etc into git, which is wonderful, but merely installing etckeeper on EL distros does not initialize and enable it like it does on Debian/Ubuntu, so it’s not part of the standard install on EL distros in Virtualmin. I probably should spend the time to make it so, since so many folks aren’t keeping good system backups. I recommend everybody use etckeeper in addition to good backups. Getting familiar with git and using it for literally everything you need a history of is just a great thing. Config files, custom scripts, your websites, everything. If it’s mostly text and changes sometimes, git is great.)

1 Like

Personally I love the virtualmin backups - it makes moving to a new server a breeze :smiley:

So my vote would be to keep the webmin backup option (assuming it backs up the same as etckeeper and in the same way the virtualmin backups work i.e where you can specify off-server as well as local backup destinations) and then all I would suggest is you move ALL backup features into one place - as I bet I wasn’t the only one who thought I was backing up everything via the virtualmin backup menu.

We probably should have some sort of consolidated backup page, where we show state of Filesystem Backups, Backup Configuration Files, and Virtualmin Backups (which are all different things, and useful in different disaster recovery scenarios, and may or may not be useful for any given Virtualmin deployment…if you’re a hosting provider with a standard OS image that goes on all systems unchanged, you don’t need the first two, you’re going to just restore Virtualmin backups whenever you need to, everything else is standard across systems). But, a lot of people don’t understand what Virtualmin is backing up, so maybe putting them all in one page would be useful to making the distinction clear.