Hey dev community! Today I'm excited to share my journey of deploying a landing page on AWS EC2, complete with SSL certification and a custom domain. Let's dive into the detailed process from server provisioning to the final deployment.
Project Overview
I created a landing page using HTML, CSS, and JavaScript, all contained in a single file. The goal was to deploy it securely on AWS EC2 and make it accessible through HTTPS. Here's how I made it happen.
Server Provisioning on AWS EC2
The first step was setting up the server infrastructure:
-
Creating the EC2 Instance
- Logged into AWS Management Console
- Selected Ubuntu Server 22.04 LTS as the AMI
- Chose t2.micro instance type (perfect for the free tier!)
- Set up security groups to allow inbound traffic on ports:
- Port 80 (HTTP)
- Port 443 (HTTPS)
- Port 22 (SSH)
-
Server Access
- Connected to the server using SSH with my key pair
- Used the command:
ssh -i my-aws-key.pem ubuntu@3.84.13.68
- Elevated to root privileges using
sudo -i
for easier management
Setting Up the Web Server
The next crucial step was installing and configuring Apache:
-
Apache Installation
- Updated the server packages
- Installed Apache web server
- Verified the installation by checking Apache's status
- Enabled Apache to start automatically on boot
-
Project Deployment
- Created a dedicated directory for the project
- Downloaded the project files from GitHub
- Installed necessary tools (like unzip)
- Moved the files to Apache's root directory
- Restarted Apache to apply changes
Domain Configuration and SSL Setup
This part was exciting - making the site secure and professional:
-
Domain Setup
- Purchased the domain 'osagieanolu.engineer' from name.com
- Linked my EC2 instance's IP address to the domain
- Set up proper DNS records
-
SSL Certificate Installation
- Installed Snapd package manager
- Used Certbot for SSL certificate generation
- Configured automatic certificate renewal
- Set up a cron job for renewal checks twice daily
The Secret Sauce: Certbot Configuration
The SSL setup was particularly interesting. Certbot made the process surprisingly straightforward:
-
Installation Process
- Installed Certbot via Snap
- Used the Apache plugin for automatic configuration
- Followed the interactive prompts for domain verification
-
Automation Setup
- Configured automatic renewals
- Verified the certificate installation
- Set up quiet renewal processes to avoid notification spam
Challenges and Solutions
During the deployment, I faced several challenges:
-
Permission Issues
- Initially struggled with file permissions in
/var/www/html/
- Resolved by properly setting ownership and access rights
- Initially struggled with file permissions in
-
DNS Propagation
- Had to wait for DNS changes to propagate
- Used DNS lookup tools to verify changes
-
Apache Configuration
- Needed to adjust Apache's default configuration
- Ensured proper virtual host setup for SSL
Final Results
The deployment was successful!
Key Takeaways
This project taught me several valuable lessons:
-
Always Plan Ahead
- Having a clear deployment strategy saves time
- Document each step for future reference
-
Security First
- SSL is crucial for modern web applications
- Regular certificate renewal is essential
-
Monitoring is Important
- Regular checks of server status
- Monitoring SSL certificate expiration
Next Steps
Future improvements I'm considering:
- Setting up a CDN for better performance
- Implementing server monitoring tools
- Adding backup automation
- Optimizing Apache configuration for better performance
For Those Following Along
If you're planning a similar deployment, here are some tips:
- Double-check all security group settings
- Keep your SSH key secure
- Document your server configuration
- Test your SSL setup thoroughly
Conclusion
Deploying a landing page on AWS with SSL might seem daunting at first, but breaking it down into steps makes it manageable. The combination of AWS EC2, Apache, and Certbot provides a robust foundation for hosting secure web applications.
Have you deployed any projects on AWS recently? What challenges did you face? Let's discuss in the comments below!
Top comments (1)
love this. very interesting and straight-forward article.