Creating SSL Certificates
This tutorial briefly covers creating new SSL certificates for your panel and kuber.
To begin, we will install certbot, a simple script that automatically renews our certificates and allows much easier creation of them. The command below is for Ubuntu distributions, but you can always check Certbot's official site (opens new window)for installation instructions. We have also included a command below to install certbot's Nginx/Apache plugin so you won't have to stop your webserver.
Creating a Certificate
After installing the certbot, we need to generate a certificate. There are a couple of ways to do that, but the easiest is to use the web server-specific certbot plugin you just installed. For Kuber-only machines that don't need a web server, use the standalone or DNS method of the certbot as you don't need a web server for it.
Then, in the command below, you should replace example.com
with the domain you would like to generate a certificate for. When you have multiple domains you would like certificates for, simply add more -d anotherdomain.com
flags to the command. You can also look into generating a wildcard certificate but that is not covered in this tutorial.
When you are using certbot's Nginx/Apache plugin, you won't need to restart your webserver to have the certificate applied assuming that you've already configured the webservers to use SSL as instructed in the web server configuration step (opens new window).
HTTP challenge
HTTP challenge requires you to expose port 80 for the challenge verification.
DNS challenge
DNS challenge requires you to create a new TXT DNS record to verify domain ownership, instead of having to expose port 80. The instructions are displayed when you run the certbot command below.
Auto Renewal
You'll also probably want to configure the automatic renewal of certificates to prevent unexpected certificate expirations. You can open crontab with sudo crontab -e
and add the line from below to the bottom of it for attempting renewal every day at 23 (11 PM).
Deploy hook would restart the Nginx service to apply a new certificate when it's renewed successfully. Change nginx
in the restart command to suit your own needs, such as to apache
or kuber
.
For advanced users, we suggest installing and using acme.sh (opens new window)which provides more options, and is much more powerful than certbot.
Troubleshooting
If you get an Insecure Connection
or SSL/TLS related error when trying to access your panel or kuber, the certificate has likely expired. This can be easily fixed by renewing the SSL certificate, although using the command certbot renew
might not do the job if port 80 is in use, as it'll return errors like: Error: Attempting to renew cert (domain) from /etc/letsencrypt/renew/domain.conf produced an unexpected error
.
This will happen especially if you're running Nginx instead of Apache. The solution for this is to use Nginx or Apache plugins with --nginx
and --apache
. Alternatively, you can stop Nginx, then renew the certificate, finally restart Nginx. Replace nginx
with your own web server or with kuber
should you be renewing the certificate for Kuber.
Stop Nginx:
Renew the certificate:
Once the process has complete, you can restart the Nginx service:
You may also need to restart Kuber as not every service is able to automatically apply an updated certificate:
Last updated