How to add a HTTPS certificate for your website with nginx, but of course you can use apache if you prefer ...
You'll need to install certbot first (can be a distribution package for your server, or you can get it directly with pip as a python package).
Then run this command :
sudo certbot --nginx -d testapi.mydomain.com
And there you go, you've just added HTTPS encryption to your website ! This certificate must be renewed by hand, depending on the settings you chose when generating it. For that, simply run the command :
sudo certbot --nginx renew --cert-name testapi.mydomain.com