Automatic LetsEncrypt SSL certificate Renewal
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):
-
Go to
Cron Jobsand add you functions name tocronservice.tasks -
Add a new Entry name like
yourFunctionName.cronExpression(in this examplerenewSSLCertificate.cronExpression) -
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!