Introduction:
Enabling HTTPS on your domain is essential for securing communications and protecting sensitive data. Certbot is a trusted tool that simplifies the process of obtaining and managing SSL/TLS certificates. In this guide, we will walk you through the steps of installing Certbot and enabling HTTPS with NGINX on Ubuntu 22.04. By following these instructions, you’ll be able to secure your domain and provide a secure browsing experience for your visitors.
Step 1: Update System Packages:
Before proceeding with the installation, it’s important to update your system packages. Open a terminal on your Ubuntu 22.04 system and run the following commands:
sudo apt update sudo apt upgrade
Enter your password if prompted and wait for the updates to complete.
Step 2: Install Certbot:
To install Certbot, use the following command in the terminal:
sudo apt install certbot
Review the packages that will be installed and type “y” to proceed. Certbot and its dependencies will be downloaded and installed on your system.
Step 3: Obtain and Install SSL Certificate:
To obtain and install an SSL certificate for your domain with NGINX, run the following command:
sudo certbot --nginx
Certbot will automatically detect your NGINX configuration and prompt you to select the domain for which you want to enable HTTPS. Follow the instructions provided by Certbot to generate and install the SSL certificate. Certbot will automatically update your NGINX configuration to enable HTTPS.
Step 4: Test SSL Configuration:
After the SSL certificate installation, it’s important to test the configuration to ensure everything is working correctly. Run the following command to perform a test on your NGINX configuration:
sudo nginx -t
If the configuration is valid, you will see a message indicating that the syntax is OK.
Step 5: Automate Certificate Renewal:
SSL certificates have an expiration date, and it’s crucial to renew them to maintain secure connections. Certbot provides an automatic renewal feature. To set up automatic certificate renewal, run the following command:
sudo certbot renew --dry-run
This command will simulate the renewal process, allowing you to test the renewal procedure without actually renewing the certificate. If the dry run is successful, Certbot will automatically renew the certificate when it’s close to expiration.
Step 6: Adjust NGINX Configuration (if necessary):
In some cases, you may need to adjust your NGINX configuration to optimize the SSL settings or redirect HTTP traffic to HTTPS. You can locate the NGINX configuration file for your domain in the /etc/nginx/sites-available
directory. Make the necessary modifications using a text editor such as Nano or Vim, and then restart NGINX for the changes to take effect.
Conclusion:
By following this step-by-step guide, you have successfully installed Certbot and enabled HTTPS on your domain with NGINX on Ubuntu 22.04. Your website is now secured with an SSL certificate, providing encrypted and trusted connections to your visitors. Regular certificate renewal through Certbot’s automatic renewal feature will ensure the continued security of your domain. Enjoy the benefits of HTTPS and provide a secure browsing experience, establishing trust and safeguarding sensitive data.