Deploying a Web Application with Nginx and SSL
Install Nginx on your Ubuntu server, configure server blocks for your domain, and set up free SSL certificates with Let's Encrypt and Certbot.
Need a server? Get $200 free credits on DigitalOcean- A secured Ubuntu 24.04 server (see exercise 2: Securing Your Linux Server)
- A domain name pointed to your server's IP address
- SSH access as a sudo user
- UFW firewall configured with ports 80 and 443 open
You need a running Linux server for this exercise. Any Ubuntu server works, but we recommend DigitalOcean for quick setup.
Get $200 in free credits to get started.
Disclosure: This is an affiliate link. We may earn a commission at no extra cost to you.
- Install and configure Nginx as a web server
- Set up server blocks (virtual hosts) for a domain
- Deploy a static website to the server
- Install Certbot and obtain a free SSL certificate from Let's Encrypt
- Configure automatic HTTP to HTTPS redirection
- Set up automatic certificate renewal
Install Nginx
Install Nginx from the Ubuntu package repository and verify it is running.
Create the Website Directory and a Sample Page
Set up the directory structure for your website and create a simple HTML page to test the configuration.
Create an Nginx Server Block
Nginx uses server blocks (similar to Apache virtual hosts) to serve different sites. Create one for your domain.
Enable the Server Block and Test
Create a symlink to enable the site, test the Nginx configuration, and reload.
Verify Your Domain Points to the Server
Before requesting an SSL certificate, your domain must resolve to your server's IP address. Verify this with dig or nslookup.
Install Certbot and Obtain an SSL Certificate
Certbot is the official Let's Encrypt client. It handles obtaining and installing SSL certificates automatically.
Verify HTTPS and HTTP Redirect
Certbot should have configured Nginx to redirect HTTP traffic to HTTPS automatically. Verify both the redirect and the SSL certificate.
Set Up Automatic Certificate Renewal
Let's Encrypt certificates expire after 90 days. Certbot installs a systemd timer to renew them automatically. Verify it is set up and test a dry run.
Found an issue?
Series:Linux Server Setup SeriesPart 3 of 5
More exercises
DevOps
Complete Web Server Automation with Ansible
Build a comprehensive Ansible playbook to automate web server deployment, configuration, and security hardening across multiple environments.
75 minutes
Linux
Running Docker Containers on Your Linux Server
Install Docker and Docker Compose on Ubuntu, run your first container, deploy a WordPress stack with docker-compose, and set up Nginx as a reverse proxy in front of your containers.
60 minutes
Linux
Linux Performance Tuning and Troubleshooting
Master essential Linux performance analysis and optimization techniques to diagnose and resolve system bottlenecks.
80 minutes
Also worth your time on this topic
Complete Web Server Automation with Ansible
Build a comprehensive Ansible playbook to automate web server deployment, configuration, and security hardening across multiple environments.
75 minutes
How to Fix "Argument List Too Long" Error for rm, cp, and mv Commands
Solve the 'argument list too long' error when working with thousands of files. Learn to use find, xargs, and loops as alternatives to wildcards for bulk file operations.
SSH Hardening Checklist
Comprehensive guide to harden your SSH server configuration and improve security.
30-45 minutes