Skip to content

SSL Installation on Lightsail

1

I have ran a small LAMP application for years on Lightsail and now need SSL to embed content elsewhere.

The app is resolving into a subdomain of my primary vanity domain I only use for this app.

I've created a SSL Certificate in my registrar (namecheap) and installed it into an AWS Distribution. The certificate is showing "Valid, In Use" but the custom domain is saying "Domain not registered to account".

Looking at my domain in AWS, I have an A record with "www.mydomain.com" pointing to the cloudfront domain. I have a CNAME record pointing to my static IP.

Looking at my registrar, I have an A record pointing to my subdomain (sub.mydomain.com).

The app continues to work in HTTP but not HTTPS, so my users are not impacted. I have no clue what is my next step. Thanks in advance for any assistance you can offer

asked 3 years ago383 views

1 Answer
0

Greeting

Hi Greg,

Thanks for reaching out! It sounds like you've got a long-standing LAMP application on Lightsail that has been working great until you hit the SSL hurdle. Let’s dive into your situation and get this sorted so your application can work seamlessly over HTTPS. 😊

Clarifying the Issue

From what you’ve shared, you’ve set up a valid SSL certificate in AWS CloudFront and configured it for your domain. However, despite the certificate showing as "Valid, In Use," your custom domain isn’t functioning correctly over HTTPS. Your Lightsail app works fine on HTTP, which indicates your users aren't impacted yet.

It seems the root of the issue may lie in the DNS configuration and how traffic is routed through CloudFront, Lightsail, and your registrar. DNS propagation time might also be playing a role. Let’s break it down step by step to troubleshoot and resolve the issue.

Key Terms

  • SSL (Secure Sockets Layer): A protocol to secure communications between users and your application via HTTPS.
  • CloudFront Distribution: A content delivery service that supports SSL termination.
  • A Record: A DNS record mapping a domain name to an IP address.
  • CNAME Record: A DNS record mapping one domain name to another.
  • Static IP: The fixed IP address assigned to your Lightsail instance.
  • DNS Propagation: The time it takes for changes to DNS records to update across the internet.

The Solution (Our Recipe)

Steps at a Glance:

  1. Verify CloudFront and Lightsail DNS configuration.
  2. Update CloudFront origin to point to the Lightsail public IP.
  3. Test HTTPS on CloudFront distribution.
  4. Modify DNS records at your registrar to use CloudFront.
  5. Redirect HTTP to HTTPS for seamless user experience.
  6. Additional Troubleshooting Tips

Step-by-Step Guide:

1. Verify CloudFront and Lightsail DNS Configuration

  • Check the configuration of your CloudFront distribution to ensure the "Origin Domain Name" points to your Lightsail instance’s public IP or domain name. You can find this in the CloudFront console under Origins and Origin Groups.
  • Ensure that the Lightsail instance allows traffic on HTTPS (port 443). Update the instance's firewall rules in the Lightsail console if needed:
sudo ufw allow https
sudo service apache2 restart

2. Update CloudFront Origin to Point to the Lightsail Public IP

  • In the CloudFront console, edit your distribution and update the "Origin Domain Name" field to match the public IP of your Lightsail instance or its DNS name (e.g., sub.mydomain.com).
  • Ensure the Origin Protocol Policy is set to HTTPS Only.

3. Test HTTPS on CloudFront Distribution

  • Use a tool like curl to test HTTPS connectivity from your CloudFront distribution:
    curl -I https://d123abc.cloudfront.net
  • Alternatively, in a browser, navigate to the CloudFront distribution domain (e.g., d123abc.cloudfront.net) using HTTPS.
  • If the application doesn’t load, check your CloudFront logs or CloudWatch metrics for error messages, such as 403 (Forbidden) or 502 (Bad Gateway).

4. Modify DNS Records at Your Registrar to Use CloudFront

  • Update the DNS records in your registrar to point your subdomain (sub.mydomain.com) to the CloudFront distribution domain using a CNAME record.

Example:

Type: CNAME  
Name: sub.mydomain.com  
Value: d123abc.cloudfront.net  
TTL: 300  
  • Remove any conflicting A or CNAME records for the same subdomain to avoid routing issues. Use tools like whatsmydns.net to confirm that DNS changes have propagated globally.

5. Redirect HTTP to HTTPS for Seamless User Experience

  • In the CloudFront console, go to Behaviors, select your behavior, and click Edit.
  • Set the "Viewer Protocol Policy" to Redirect HTTP to HTTPS.
  • Save the changes, and this will automatically redirect all HTTP traffic to HTTPS.

6. Additional Troubleshooting Tips

  • Ensure your SSL certificate covers the exact subdomain (sub.mydomain.com). If not, you might need to create a wildcard certificate or an exact match in AWS Certificate Manager (ACM).
  • If your Lightsail instance is not serving HTTPS properly, double-check your Apache or Nginx configuration files to ensure the SSL module is enabled and configured:
    sudo a2enmod ssl
    sudo service apache2 restart

Closing Thoughts

Here are some helpful resources to guide you further:

Let me know how it goes, Greg, and feel free to reach out if you need more help troubleshooting! 😊

Farewell

Good luck with setting up HTTPS, Greg! Once this is sorted, your app will be more secure and ready for embedding anywhere you like. You've got this! 🚀🌟


Cheers,

Aaron 😊

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.