Create an A record: Type A, Name api, Value (your Elastic IP). Then add an Nginx server block with server_name api.yourdomain.com and the appropriate proxy_pass or root. Finally, get SSL with sudo certbot --nginx -d api.yourdomain.com.
How do I set up subdomains like api.yourdomain.com?
More FAQs in Configuring DNS Records for AWS EC2 A Records, CNAME, and Subdomains
First allocate an Elastic IP and associate it with your instance. Then create an A record in your DNS provider: Type A, Name @ (for root) or api (for subdomain), Value (your Elastic IP). Verify with dig yourdomain.com A +short.
The default public IP changes when you stop and start the EC2 instance. An Elastic IP is a static IP that persists across stop/start cycles. Without it, your DNS A record would point to the wrong IP after a restart.
Create a hosted zone for your domain, update nameservers at your registrar, then create records: A record for root (empty name, Elastic IP value), A record for subdomains (api, Elastic IP), and CNAME for www (yourdomain.com).
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.