usmannasir / cyberpanel

Cyber Panel - The hosting control panel for OpenLiteSpeed
GNU General Public License v3.0
1.6k stars 613 forks source link

[FEATURE] Re-generate Openlitespeed/Litespeed Configuration #1079

Open jordantrizz opened 1 year ago

jordantrizz commented 1 year ago

Describe the bug When the openlitespeed configuration becomes corrupt, there is no method to re-generate the configuration.

To Reproduce

  1. Delete half of the /usr/local/lsws/config/httpd.conf or remove a vhost file.

Expected behavior A command that regenerates the openlitespeed configuration.

Additional context If any thing is corrupted with the openlitespeed configuration, there is no method to restore the configuration.

Dreamer41 commented 1 year ago

How about using backups or snapshot from provider?

jordantrizz commented 1 year ago

How about using backups or snapshot from provider?

Sure, that's an option. But this is available in cPanel and GridPane.

jcn50 commented 1 year ago

@jordantrizz 1) can you change the title from [BUG] to [FEATURE] and add a proper description? 2) why would the .conf file become corrupted in the first place?.. Full disk? Manual editing? Regeneration of a config file is not a solution to (bad) system management.... 3) You can always restore from Github: https://github.com/usmannasir/cyberpanel/blob/stable/serverStatus/litespeed/httpd.conf https://github.com/usmannasir/cyberpanel/blob/stable/install/litespeed/httpd.conf

jordantrizz commented 1 year ago
  1. can you change the title from [BUG] to [FEATURE] and add a proper description?

Done.

2. why would the .conf file become corrupted in the first place?.. Full disk? Manual editing?

I created this issue due to investigating an issue for a friend; they had an outdated Cyberpanel instance which had two hacked WordPress sites. There were random characters on a couple of the Openlitespeed vhost configuration files, which caused only half the sites to function on the server.

Regeneration of a config file is not a solution to (bad) system management....

That's a valid opinion. However, re-generating a default configuration should be an option, it's the same as creating a new site. What happens if Cyberpanel encounters a bug and writes a malformed configuration file? What is the remote transfer tool using?

jordantrizz commented 1 year ago

It happened again. Don't know why these @^ are showing up.

virtualHost site1.com {
  vhRoot                  /home/$VH_NAME
  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhost.conf
  allowSymbolLink         1
  enableScript            1
  restrained              1
}
virtualHost site2.com {
  vhRoot                  /home/$VH_NAME
  configFile              $SERVER_ROOT/conf/vhosts/$VH_NAME/vhost.conf
  allowSymbolLink         1
  ena^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@bleScript            1
  restrained              1
}
jordantrizz commented 11 months ago

@jcn50

  • why would the .conf file become corrupted in the first place?.. Full disk? Manual editing? Regeneration of a config file is not a solution to (bad) system management....

You saw my example, don't know where that is coming from, but this server had a couple of sites hacked. Do you have any idea why this might have happened? I've googled and haven't found anything.

Sure, but that doesn't regenerate the current server configuration for all the sites and configuration that have been set. I'm assuming that this is all in the database so that changes can be logged and tracked to allow for auditing and version control?

jordantrizz commented 10 months ago

Had this happen again, the same characters are showing up for different sites in different sections. But I was able to dig deeper.

^@ is the character which is (ASCII value 0)

You can remove it using tr

tr -d '\0' < httpd_config.conf > httpd_config.conf.fixed
jordantrizz commented 2 months ago

This hasn't happened again, just curious if this was fixed?