0
0
Nginxdevops~30 mins

Let's Encrypt with Certbot in Nginx - Mini Project: Build & Apply

Choose your learning style9 modes available
Let's Encrypt with Certbot
📖 Scenario: You are setting up a secure website using nginx web server. To make your website safe, you want to add a free SSL certificate from Let's Encrypt. This certificate will encrypt the data between your website and visitors.We will use Certbot, a tool that helps get and install these certificates automatically.
🎯 Goal: Learn how to configure nginx and use Certbot to get a Let's Encrypt SSL certificate and enable HTTPS on your website.
📋 What You'll Learn
Create a basic nginx server block configuration file for your domain
Add a variable for your domain name
Use Certbot command to request and install the SSL certificate
Show the nginx status to confirm HTTPS is enabled
💡 Why This Matters
🌍 Real World
Websites need SSL certificates to secure user data and improve trust. Let's Encrypt provides free certificates, and Certbot automates their installation and renewal.
💼 Career
Many DevOps and system administrator roles require setting up secure web servers with automated SSL management to ensure safe and reliable web services.
Progress0 / 4 steps
1
Create nginx server block configuration
Create a file named /etc/nginx/sites-available/example.com with this exact content:
server {
    listen 80;
    server_name example.com www.example.com;

    root /var/www/example.com/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}
Nginx
Need a hint?

This is the basic nginx configuration for your website listening on port 80 (HTTP).

2
Add domain variable for Certbot
Create a shell variable named DOMAIN and set it to example.com.
Nginx
Need a hint?

This variable will be used in the Certbot command to specify your domain.

3
Request and install SSL certificate with Certbot
Write the Certbot command to request and install a Let's Encrypt SSL certificate for the domain stored in $DOMAIN. Use the nginx plugin and run it in non-interactive mode with email admin@example.com and agree to terms of service.
Nginx
Need a hint?

This command tells Certbot to use the nginx plugin to automatically configure SSL for your domain.

4
Check nginx status to confirm HTTPS
Write the command to check the nginx service status to confirm it is running with the new SSL configuration.
Nginx
Need a hint?

This command shows if nginx is active and running with the new SSL setup.