Securing the API
Securing the API with TLS.
This documentation is actively being improved. You may encounter gaps or incomplete sections as we refine and expand the content. We appreciate your understanding and welcome any feedback to help us make this resource even better!
Securing Fonoster’s API with Let’s Encrypt certificates is essential to ensure encrypted communication. This process involves setting up a temporary Nginx server, obtaining the certificate, and configuring auto-renewal.
Here are the steps to accomplish this task:
Prepare the environment
First, create the necessary directories:
Configure Nginx
Next, create Nginx’s configuration file with the following content:
Replace api.example.com
with your domain name, and remember to point the domain to the server’s IP address.
Start the container
Then, start the Nginx container to handle the ACME challenge:
Retrieve the certificates
Now, run Certbot to obtain the Let’s Encrypt certificate:
Replace the email and domain name with your information.
You should see a message indicating that the certificate was successfully obtained.
Remove the container
After obtaining the certificate, stop and remove the temporary Nginx container:
Set the auto-renewal
Next, set up auto-renewal by creating a script named renew_cert.sh
:
Please replace /path/to
with the actual path to the directories.
Make the script executable and add a cron job to run it twice daily:
Replace /path/to
with the actual path to the script.
Finalize settings and run the process
Finally, find the Envoy container in your compose file, mount the Let’s Encrypt certificates, and open port 443
.
By following these steps, you’ll have successfully secured Fonoster’s API with Let’s Encrypt certificates and set up auto-renewal to maintain the security of your communications.