0
0
Nginxdevops~30 mins

SSL certificate installation in Nginx - Mini Project: Build & Apply

Choose your learning style9 modes available
SSL Certificate Installation with Nginx
📖 Scenario: You are setting up a secure website using Nginx web server. To protect user data, you need to install an SSL certificate so that the website uses HTTPS instead of HTTP.This project will guide you step-by-step to configure Nginx to use SSL certificates correctly.
🎯 Goal: Configure Nginx to serve a website over HTTPS by installing SSL certificate files and updating the server block configuration.
📋 What You'll Learn
Create a basic Nginx server block configuration for HTTP
Add variables for SSL certificate and key file paths
Modify the server block to listen on port 443 with SSL enabled
Print the final Nginx server block configuration
💡 Why This Matters
🌍 Real World
Installing SSL certificates is essential to secure websites and protect user data during transmission. Nginx is a popular web server used in many real-world projects.
💼 Career
Understanding how to configure SSL in Nginx is a key skill for DevOps engineers, system administrators, and web developers working on secure web hosting.
Progress0 / 4 steps
1
Create a basic Nginx server block configuration
Create a variable called nginx_config and assign it a string containing a basic Nginx server block that listens on port 80 for the domain example.com and serves files from /var/www/html. Use the exact text below inside the string:
server {
    listen 80;
    server_name example.com;
    root /var/www/html;
}
Nginx
Need a hint?

Use triple quotes or escape newlines with \n inside the string.

2
Add SSL certificate and key file path variables
Create two variables: ssl_certificate with the value "/etc/ssl/certs/example.com.crt" and ssl_certificate_key with the value "/etc/ssl/private/example.com.key".
Nginx
Need a hint?

Assign the exact file paths as strings to the variables.

3
Update the Nginx config to enable SSL
Update the nginx_config variable to a new string that configures Nginx to listen on port 443 with SSL enabled for example.com. Include the lines listen 443 ssl;, ssl_certificate with the value of the ssl_certificate variable, and ssl_certificate_key with the value of the ssl_certificate_key variable. Keep the server_name and root lines unchanged. Use an f-string to insert the certificate paths.
Nginx
Need a hint?

Use an f-string to insert the ssl_certificate and ssl_certificate_key variables inside the config string.

4
Print the final Nginx configuration
Write a print statement to display the value of the nginx_config variable.
Nginx
Need a hint?

Use print(nginx_config) to show the final configuration.