Automatic LetsEncrypt SSL certificate Renewal

alex.agasiev
Alexander
DevOps

If you run structr on a server directly connected to internet, it is highly recommended to use SSL to protect you application.
Structr has an buildIn service for LetsEncrypt SSL certifcates.

However, these ceritifates are only valid for three months, so you has to reissue them periodically.

You can solve this by creating an User-defined function and trigger it via structr’s cron service.

Function Name: renewSSLCertificate

Function Body:

{
	$.maintenance('letsencrypt', {server: 'production', challenge: 'http', wait: '10', reload: true});
}

Now you can configure cron task in structr config backend (/structr/config):

  1. Go to Cron Jobs and add you functions name to cronservice.tasks

  2. Add a new Entry name like yourFunctionName.cronExpression (in this example renewSSLCertificate.cronExpression)

  3. Define the cron expression like 15 31 3 17 * * (At 03:31:15 AM, on day 17 of the month) [Yes, you can define also seconds for cron jobs in structr]

That’s it!

87

Automatic LetsEncrypt SSL certificate Renewal

Discard