Custom URL in AWS Elastic Beanstalk
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
AWS Elastic Beanstalk is a platform as a service (PaaS) that enables developers to deploy and manage applications in the AWS Cloud without worrying about the infrastructure that runs those applications. One of the common requirements for applications deployed on Elastic Beanstalk is to have custom URLs that are easy to remember and manage. This article details how to configure a custom URL for a web application hosted on AWS Elastic Beanstalk.
Understanding AWS Elastic Beanstalk URLs
When you deploy an application using AWS Elastic Beanstalk, AWS automatically assigns a default URL for your application. This URL typically looks like http://
<environment-name>
.
<region>
.elasticbeanstalk.com
. For example, an application in the North Virginia region might have a URL like http://myapp-env.eba-abc123xyz.us-east-1.elasticbeanstalk.com
.
While the default URL is functional, it's not user-friendly or branded. A custom domain name is often preferred to align with corporate branding and improve user experience. To implement this, you'll need to take a few additional steps.
Steps to Set Up a Custom URL
- Register a Domain Name:
- Before you can map a custom domain to your application, you first need to register a domain name. AWS offers a service called Amazon Route 53, which provides domain registration capabilities. Alternatively, you can use any domain registrar of your choice.
- Create an Elastic Beanstalk Environment:
- Deploy your application on AWS Elastic Beanstalk if you haven't done so already. This will give you an auto-generated Elastic Beanstalk URL.
- Configure Route 53 (or Your DNS Provider):
- Create a hosted zone for your domain in Route 53. If using a different DNS provider, ensure that the domain's name servers are pointed to your DNS provider.
- Add a CNAME record in your DNS settings so that your domain (e.g.,
www.yourdomain.com) points to your Elastic Beanstalk environment's auto-generated URL.
- Verify Domain Ownership:
- If using SSL with your custom domain, you need to verify domain ownership. This can be easily done via Route 53 using a DNS validation method.
- Request an SSL Certificate (Optional):
- For secure HTTP communication (HTTPS), request an SSL certificate from AWS Certificate Manager (ACM). Ensure that the certificate covers all the desired domain names (e.g.,
www.yourdomain.comandyourdomain.com).
- Configure Elastic Load Balancer (ELB):
- Access the Elastic Beanstalk environment’s load balancer settings in the AWS Management Console.
- In the "Listeners" tab, configure HTTPS listeners if you are using SSL, and associate your SSL certificate with the load balancer.
- Update Security Groups:
- Ensure that the security groups associated with your Elastic Beanstalk environment allow inbound connections on the necessary ports (
80for HTTP and443for HTTPS).
- Test Your Setup:
- Verify that your application is accessible via the custom domain URL. Ensure that both HTTP and HTTPS requests are appropriately handled if SSL is configured.
Key Considerations
When setting up a custom URL, keep the following points in mind:
- Cost: Domain registration, Route 53 hosted zones, and SSL certificates can incur additional costs.
- DNS Propagation: Changes to DNS records may take some time to propagate across the internet.
- Elastic Beanstalk Scaling: Automatic scaling or changes to your Elastic Beanstalk environment may require updates to DNS settings or SSL certificates.
Technical Examples
DNS Configuration Example
Suppose you've registered example.com
. Here's a sample CNAME entry:
| Name | Type | Value |
| www.example.com | CNAME | myapp-env.eba-abc123xyz.us-east-1.elasticbeanstalk.com |
AWS CLI Commands
To automate some of the steps, the AWS CLI can be utilized:
- AWS Elastic Beanstalk Console: Interface for managing Beanstalk environments.
- Amazon Route 53: DNS web service for domain registration and routing.
- AWS Certificate Manager: Tool for managing SSL/TLS certificates.

