Skip to main content

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
intermediate
cloud
Linux
60 minutes
8 steps
Prerequisites
  • 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.

Get Started with DigitalOcean

Disclosure: This is an affiliate link. We may earn a commission at no extra cost to you.

Learning Objectives
  • 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
Technologies Used
Ubuntu 24.04
Nginx
Certbot
Let's Encrypt
SSL/TLS
Exercise Steps
1

Install Nginx

Current

Install Nginx from the Ubuntu package repository and verify it is running.

2

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.

3

Create an Nginx Server Block

Nginx uses server blocks (similar to Apache virtual hosts) to serve different sites. Create one for your domain.

4

Enable the Server Block and Test

Create a symlink to enable the site, test the Nginx configuration, and reload.

5

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.

6

Install Certbot and Obtain an SSL Certificate

Certbot is the official Let's Encrypt client. It handles obtaining and installing SSL certificates automatically.

7

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.

8

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?