usmannasir / cyberpanel

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

[BUG] Install Using Remote Database fails due to using public IP #1048

Open cagivacode opened 1 year ago

cagivacode commented 1 year ago

The Install scipt to use a remote database fails due to IP detection.

To Reproduce What steps did you take when the issue occurred?

  1. Setup remote mysql
  2. use standard install script
  3. select remote mysql

Expected behavior this fails and there is no way to correct the issue

*Operating system: Ubuntu 22.04 LTS)

CyberPanel version: latest 2.3.

Additional context I have been running Cyberpanel for years on a vps with no issues (centos 7). A little tight on memory with the growth in my websites. I was offered a dedicated MYSQL slice at a good price...offloading the database to a fast server and getting all that memory back for the websites.

Here is the issue....the database server can only be reached through the internal (private) ip address for security. The install script did create the database on the remote server...but then it pulled the PUBLIC IP of the vps.

The script created the MYSQL user cyberpanel@mypublicip, then tried to access the database with the correct cyberpanel@myprivateip. which failed.

Once the script has failed there is no way to correct the issue. I corrected the user in the remote DB, but the cyberpanel install script says "cyberpanel" already installed and will not resume the install.

ERROR "lscpd.service could not be found." and upgrade.sh does not recognize ubuntu 22.04

cagivacode commented 1 year ago

There are two issues here:

One: is that the script automatically creates a DB users tied to the PublicIP of the server even when the remote server is on a private vlan. You should have a choice to correct this, because if it is wrong the script fails with a partial install.

Two: once the install script fails there is no way for it to resume, it says CP is already installed even when it is not.

I did the install the long way, full local install | move the database to the remote server | change the CP config for the remote server | and remove the local DB. This is very messy as the config for other services are also set for localhost.

Running with a remote MYSQL server on an VLAN is both cost effective and impressively fast. It is also more secure that the Mysql server is not open to the public internet. You would think more people would be interested in this option.

milossh commented 1 year ago

I have the same issue using Linode's managed DB cluster. For what it's worth, this can be overriden. Instead of using install script in the guide, download cyberpanel.sh to your local machine, change line 205 to read

Server_IP="actual private ip address here"

NOTE: You need to visit https://cyberpanel.sh/?dl&MY_OS_SLUG_HERE

Check the os slug before downloading file. Also, download with curl or else you won't have line breaks nor indentation.

PS. If you're trying to make it work with linode's managed db cluster, it still won't work. You need to switch off ssl on your db server, and you need to lower your password policy for everything to work.

kenny-nt commented 1 year ago

I thinks it should create 'cyberpanel'@'%' instead of 'cyberpanel'@'ip'. And should be forced to enter a strong password for cyberpanel user if choose remote database.