In your site’s security settings, you can enable Allow traffic from Cloudflare only.
The command clpctl cloudflare:update:ips is being executed every morning at 6 AM via cron job and updates the following file:
/etc/nginx/cloudflare/ips
If you enable Allow traffic from Cloudflare only, the file is included in the vhost of your site.
In the Admin Area, you can enable Basic Auth as additional layer of security in front of CloudPanel if you don’t have a static IP to close port 8443.
clpctl cloudpanel:enable:basic-auth --userName=john.doe --password='password123'
clpctl cloudpanel:disable:basic-auth
The Database Show Master Credentials command shows Host, User Name, Password, and the Port.
clpctl db:show:master-credentials
The output will look like:
To connect to the database server, copy the Connect Command and enter the command in the command line.
With the command db:add, you can add a database to your site.
clpctl db:add --domainName=www.domain.com --databaseName=my-database --databaseUserName=john --databaseUserPassword='!secretPassword!'
With the command db:export, you can export a database as dump.
The database dump will be gzipped if you add .sql.gz at the end of the file name. If you want to export the database uncompressed, use .sql.
clpctl db:export --databaseName=my-database --file=dump.sql.gz
To import a database, go to the database dump’s directory and use the following command to import.
clpctl db:import --databaseName=my-database --file=dump.sql.gz
With the lets-encrypt:install:certificate command, you can issue and install a Let’s Encrypt Certificate for a site.
clpctl lets-encrypt:install:certificate --domainName=www.domain.com
The parameter subjectAlternativeName is optional and is needed if you want to issue a certificate for multiple domains.
clpctl lets-encrypt:install:certificate --domainName=www.domain.com --subjectAlternativeName=domain1.com,www.domain1.com
Node 16 LTS, Node 14 LTS, Node 12 LTS are available. The Node.js Versions are managed via Node Version Manager.
If you need another version, you can change the version afterward.
To add a Node.js Site, use the following command.
clpctl site:add:nodejs --domainName=www.domain.com --nodejsVersion=16 --appPort=3000 --siteUser=john --siteUserPassword='!secretPassword!'
To add a Static HTML Site, use the following command.
clpctl site:add:static --domainName=www.domain.com --siteUser=john --siteUserPassword='!secretPassword!'
For Adding a PHP Site, it’s important to use the right Vhost Template.
With the command vhost-templates:list, you can display all available vhost templates:
clpctl vhost-templates:list
The vhost templates can be found on Github. They will be updated every night.
Copy the name of the template and use the following command to create a PHP Site:
clpctl site:add:php --domainName=www.domain.com --phpVersion=8.1 --vhostTemplate='Generic' --siteUser=john --siteUserPassword='!secretPassword!'
To add a Reverse Proxy, use the following command:
clpctl site:add:reverse-proxy --domainName=www.domain.com --reverseProxyUrl='http://127.0.0.1:8000' --siteUser=john --siteUserPassword='!secretPassword!'
To install a certificate for a site, use the following command below. The certificateChain argument is optional.
clpctl site:install:certificate --domainName=www.domain.com --privateKey=/path/to/private.key --certificate=/path/to/certificate.crt --certificateChain=/path/to/chain.crt
To delete a Site, use the following command:
clpctl site:delete --domainName=www.domain.com
Confirm your action by entering yes. It’s also possible to force the deletion by adding the “–force” parameter as seen below:
clpctl site:delete --domainName=www.domain.com --force
To add a User, see the following commands as example.
To add an admin user, use the following command:
clpctl user:add --userName='john.doe' --email='john.doe@domain.com' --firstName='John' --lastName='Doe' --password='!password!' --role='admin' --timezone='UTC' --status='1'
To add a site manager, use the following command:
clpctl user:add --userName='john.doe' --email='john.doe@domain.com' --firstName='John' --lastName='Doe' --password='!password!' --role='site-manager' --timezone='UTC' --status='1'
To add a user who is restricted to specific sites, use the following command:
clpctl user:add --userName='john.doe' --email='john.doe@domain.com' --firstName='John' --lastName='Doe' --password='!password!' --role='user' --sites='domain.com,domain.io' --timezone='UTC' --status='1'
clpctl user:delete --userName='john.doe'
To list all users, use the following command:
clpctl user:list
To reset the password for a CloudPanel user, you can use the user:reset:password command:
clpctl user:reset:password --userName=john.doe --password='!newPassword!'
To disable Two-Factor Authentication for a user, run the following command:
clpctl user:disable:mfa --userName=john.doe
The command vhost-templates:import is being executed every night. It updates the Vhost Templates from our Github Repository.
clpctl vhost-templates:import
The command vhost-templates:list lists all Vhost Templates that can be used for adding a PHP Site.
clpctl vhost-templates:list
If you need a custom Vhost Template for your PHP Application, you can do the following:
#{"rootDirectory":"public","phpVersion":"8.1"} server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; {{ssl_certificate_key}} {{ssl_certificate}} {{server_name}} {{root}} {{nginx_access_log}} {{nginx_error_log}} if ($scheme != "https") { rewrite ^ https://$host$uri permanent; } location ~ /.well-known { auth_basic off; allow all; } {{settings}} try_files $uri $uri/ /index.php?$args; index index.php index.html; location ~ \.php$ { include fastcgi_params; fastcgi_intercept_errors on; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; try_files $uri =404; fastcgi_read_timeout 3600; fastcgi_send_timeout 3600; fastcgi_param HTTPS $fastcgi_https; fastcgi_pass 127.0.0.1:{{php_fpm_port}}; fastcgi_param PHP_VALUE "{{php_settings}}"; } location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm|webp|zip|swf)$ { add_header Access-Control-Allow-Origin "*"; expires max; access_log off; } if (-f $request_filename) { break; } }
#{"rootDirectory":"public","phpVersion":"8.1"}
Setting the rootDirectory and phpVersion is very important to prefill the site wizard form.
Most PHP Applications use public nowadays as an entry point.
To import your template from a file, use the following command:
clpctl vhost-template:add --name='My Application' --file=/tmp/template.tpl
To import your template from remote e.g, from a gist, use the following command:
clpctl vhost-template:add --name='My Application' --file=https://gist.githubusercontent.com/swieczorek/1c344ca356118c45b7c1b7393cc00abc/raw/007ff01dff96978be65dca212990ac20f6fd16be/gistfile1.txt
When you select My Application, it will prefill the PHP Version, which has been defined in the Vhost Template.
When you click on Create, the root directory for the NGINX VHost will be generated with the following pattern:
/home/$siteUser/htdocs/$domainName/$rootDirectory
In our example, the root directory would be:
/home/custom-app/htdocs/www.domain.com/public
With the command vhost-template:delete, you can delete a Vhost Template:
clpctl vhost-template:delete --name='My Application'
With the command vhost-template:view, you can view a Vhost Template:
clpctl vhost-template:view --name='My Application'
To reset the permissions of a file or directories, log in via SSH and modify the command below to your needs:
clpctl system:permissions:reset --directories=770 --files=660 --path=.
With the command db:export, you can export a database as dump.
clpctl db:export --databaseName=my-database --file=dump.sql.gz
To import a database, go to the database dump’s directory and use the following command to import.
clpctl db:import --databaseName=my-database --file=dump.sql.gz
With the command varnish-cache:purge, you can purge everything, specific cache tags or a single url.
To purge the entire cache, use the following command:
clpctl varnish-cache:purge --purge=all
Specific cache tags, separated by a comma, can be purged with the following command:
clpctl varnish-cache:purge --purge='tag1,tag2'
In case you want to purge a single url only:
clpctl varnish-cache:purge --purge='https://www.domain.com/site.html'