Home › Courses › Free SSL on AWS EC2 IP Without a Domain | Nginx HTTPS Setup

Free SSL on AWS EC2 IP Without a Domain | Nginx HTTPS Setup

https://youtu.be/caJZqWTU7j8
81 / 81

SSL Setup on AWS EC2 with Nginx

OS: Amazon Linux 2023

Example IP: 44.204.120.121 — replace with your public IP.

1. Open AWS Ports

In your EC2 Security Group, allow:

  1. HTTP — Port 80
  2. HTTPS — Port 443
  3. Source — 0.0.0.0/0

2. Install Certbot

sudo dnf install -y python3.11
sudo python3.11 -m venv /opt/certbot
sudo /opt/certbot/bin/pip install --upgrade pip certbot
sudo /opt/certbot/bin/certbot --version

Use Certbot 5.4 or newer.

3. Configure Verification

sudo mkdir -p /var/www/letsencrypt
sudo chmod 755 /var/www/letsencrypt
sudo nano /etc/nginx/nginx.conf

Add inside your existing port 80 server block:

location ^~ /.well-known/acme-challenge/ {
root /var/www/letsencrypt;
default_type text/plain;
try_files $uri =404;
}

Save and reload:

sudo nginx -t && sudo systemctl reload nginx

4. Generate SSL Certificate

sudo /opt/certbot/bin/certbot certonly \
--webroot \
--webroot-path /var/www/letsencrypt \
--preferred-profile shortlived \
--ip-address 44.204.120.121 \
--cert-name ec2-ip

Enter your email and accept the terms. Continue after successful issuance.

5. Enable HTTPS

sudo nano /etc/nginx/nginx.conf

Add inside the same server block, keeping your existing settings:

listen 443 ssl;

ssl_certificate /etc/letsencrypt/live/ec2-ip/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ec2-ip/privkey.pem;

ssl_protocols TLSv1.2 TLSv1.3;

Save and reload:

sudo nginx -t && sudo systemctl reload nginx

6. Test HTTPS

curl -I https://44.204.120.121

Open in your browser:

https://44.204.120.121

Note: IP certificates last about six days. Renewal setup is not included here.

Share this lesson: