Skip to content

Getting https access

0

Gunicorn is running successfully and Nginx is active on my server. However, when I run the command dig mydomain.com +short, it returns no output, which means there is no DNS record for that domain. How can I set up DNS correctly and get HTTPS access to my application?

asked a year ago225 views

2 Answers
0

To set up DNS correctly and enable HTTPS for your application, you need to follow these steps:

  1. Set up DNS records:
  • First, you need to create a DNS record that points your domain to your EC2 instance's public IP address.
  • You can use Amazon Route 53 or your domain registrar to create an A record that maps your domain name to your EC2 instance's IP address.
  • After creating the DNS record, verify it by running dig mydomain.com +short again. It should return your EC2 instance's public IP address.
  1. Verify DNS resolution:
  • Once your DNS is set up, verify that both your domain resolves to your EC2 instance's IP and that your web server is responding:
FQDN=mydomain.com
curl checkip.amazonaws.com && dig +short $FQDN
curl -I $FQDN
  • Both IP addresses should match, and the curl command should return a successful HTTP response.
  1. Enable HTTPS on your EC2 instance:
  • For EC2 instances, you can use Certbot to obtain and install a free SSL certificate from Let's Encrypt:
  • Install Certbot and its Nginx plugin
  • Request and install the certificate with Certbot
  • Certbot will automatically configure Nginx to use the certificate
  1. Alternative approach with AWS services:
  • If you prefer using AWS services for HTTPS:
  • Create a CloudFront distribution pointing to your EC2 instance
  • Request an SSL/TLS certificate through AWS Certificate Manager (ACM)
  • Configure CloudFront to use HTTPS (set "Viewer Protocol Policy" to "Redirect HTTP to HTTPS" or "HTTPS Only")
  • Update your DNS records to point to the CloudFront distribution

Remember to ensure your security groups allow inbound traffic on ports 80 (HTTP) and 443 (HTTPS) from the internet to your EC2 instance.
Sources
https not working | AWS re:Post
Use Certbot to enable HTTPS with Apache or Nginx on EC2 instances running Amazon Linux 2023 (AL2023) | AWS re:Post
Use Certbot to enable HTTPS with Apache or Nginx on EC2 instances running Amazon Linux 2 (AL2) | AWS re:Post

answered a year ago

0

If you are using domain registered with Lightsail, in the DNS zone that Lightsail created when you registered the domain, create records to tell Lightsail how you want to route traffic for the domain and subdomains. follow up this User Guide https://docs.aws.amazon.com/lightsail/latest/userguide/lightsail-how-to-create-dns-entry.html#lightail-add-records-to-the-dns-zone

If you are using Route 53 domain or other registrar. You can follow this User Guide to create a DNS zone and add records https://docs.aws.amazon.com/lightsail/latest/userguide/lightsail-how-to-create-dns-entry.html

Here is the guide to setup HTTPS access by Let's Encrypt SSL/TLS https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-using-lets-encrypt-certificates-with-nginx.html

AWS
MODERATOR

answered a year 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.