Rehmat Alam A blogger who has fallen in love with coding! Here at SupportiveHands.net, I share things that relate to coding, servers, E-marketing, and other related fields.

Let’s Encrypt for ServerPilot Free Plan

1 min read

ServerPilot’s free plan doesn’t let you enable SSL on your apps using their web-based interface but if you need to install SSL certs on your apps in a ServerPilot free server, then I’ve brought you a useful Python package (available via PIP) that will automate the SSL installation for you.

Getting Started

Sign into your server as root using an SSH client and then install the package using PIP. If PIP isn’t installed on your system, first install it:

apt install python-pip

And then install rwssl package:

pip install rwssl

Once installed, you will have a new command rwssl available in your SSH client.

Installing SSLs

Type rwssl -h and you will get help on commands available to install, uninstall and renew SSL certificates.

usage: rwssl [-h] [-a] [-f] [-i IGNOREAPPS] [-n APPNAME] [-r] [-ic] [-dc]
             [-ap] [-na] [-re] [-redir REDIRECT] [-noredir NOREDIRECT]

A Python script that automates the SSL installation on Ubuntu servers managed
by ServerPilot.io.

optional arguments:
  -h, --help            show this help message and exit
  -a, --all             Install SSL for all available apps.
  -f, --fresh           Obtain and install SSL certificates for new (non-ssl)
                        apps only.
  -i IGNOREAPPS, --ignore IGNOREAPPS
                        Comma-seperated app names to ignore some apps and
                        install SSL for all others.
  -n APPNAME, --name APPNAME
                        Name of the app where SSL should be installed.
  -r, --renew           Renew all installed SSL certificates which are about
                        to expire.
  -ic, --installcron    Install the cron job for SSL renewals.
  -dc, --deletecron     Uninstall the cron job responsible for SSL renewals.
  -ap, --autopilot      A CRON job that attempts to automatically obtain SSL
                        certificates for newly added apps.
  -na, --noautopilot    Disable Autopilot mode and disable automatic SSLs for
                        your apps.
  -re, --refresh        Cleans all previous SSL vhost files, reinstalls the
                        SSLs and reloads nginx. Only needed if you are having
                        issues on a server with old SSL installations.
  -redir REDIRECT, --redirect REDIRECT
                        Apply a 301 redirect from HTTP to HTTPs for a given
                        app or for all apps.
  -noredir NOREDIRECT, --noredirect NOREDIRECT
                        Disable HTTP to HTTPs redirect for a single app or for
                        all apps.

For example to install SSL certificate on all available apps, you will need to run rwssl -a or rwssl --all. Both commands will perform the same action.

Upgrading

If you are using my old script, then you need to first delete it and then follow the Getting Started section in this guide:

rm /usr/local/bin/rwssl && pip install rwssl

Upgrading to a newer version is super-easy:

pip install --upgrade rwssl

Uninstall

To uninstall rwssl, simply do:

pip uninstall rwssl

And then delete the added CRON jobs:

# Delete SSL renewal cron
rm /etc/cron.d/rwsslrenew
# Also delete auto-pilot cron
rm /etc/cron.d/rwssl

The package is hosted at GitHub and PyPi. If you have any issue with rwssl, then you can either leave a comment below or open an issue at GitHub page.

Rehmat Alam A blogger who has fallen in love with coding! Here at SupportiveHands.net, I share things that relate to coding, servers, E-marketing, and other related fields.

Leave a Reply

Your email address will not be published. Required fields are marked *