How to Set Up an HTTPS LoadBalancer
In this example, you create a LoadBalancer for an HTTPS service. Currently, Elastic Load Balancing does not have SSL termination capability. For HTTPS traffic, you need to set the LoadBalancer listener protocol to TCP. You specify that the LoadBalancer listens on port 443 and distributes traffic to port 8443 on the instances. You also specify that Availability Zone us-east-1a is enabled for your LoadBalancer. Once the LoadBalancer is created, you configure an application health check for the instances, and register the instances with the LoadBalancer.
Preconditions:
-
Your AWS account is signed up for Amazon EC2
-
In Availability Zone us-east-1a, you have launched the instances you intend to register with your LoadBalancer
-
The instances to be registered with your LoadBalancer accept TCP connections on the port specified in the target of the health check
API Example
To set up an HTTPS LoadBalancer
-
Call CreateLoadBalancer with the following parameters:
-
AvailabilityZones =
us-east-1a
-
Listeners
-
Protocol
=TCP
-
InstancePort
=8443
-
LoadBalancerPort
=443
-
-
LoadBalancerName
=MyLoadBalancer
The operation returns the DNS name of your LoadBalancer. You can then map that to any other domain name (such as www.mywebsite.com) using CNAME or some other technique.
-
-
Call ConfigureHealthCheck with the following parameters:
-
LoadBalancerName
=MyLoadBalancer
-
Target
=TCP:8443
Note Make sure your instances accept TCP connections on port 8443. -
Interval
=30
-
Timeout
=3
-
HealthyThreshold
=2
-
UnhealthyThreshold
=2
-
-
Call RegisterInstancesWithLoadBalancer with the following parameters:
-
LoadBalancerName
=MyLoadBalancer
-
Instances = [
i-4f8cf126
,i-0bb7ca62
]
-
Command Line Tools Example
To set up an HTTPS LoadBalancer
-
Use the elb-create-lb command as in the following example.
PROMPT> elb-create-lb MyLoadBalancer --headers --listener "lb-port=443,instance-port=8443,protocol=TCP" --availability-zones us-east-1a
Elastic Load Balancing returns the following:
DNS-NAME DNS-NAME DNS-NAME MyLoadBalancer-2111276808.us-east-1.elb.amazonaws.com
-
Use the elb-configure-healthcheck command as in the following example.
PROMPT> elb-configure-healthcheck MyLoadBalancer --headers --target "TCP:8443" --interval 30 --timeout 3 --unhealthy-threshold 2 --healthy-threshold 2
Elastic Load Balancing returns the following:
HEALTH-CHECK TARGET INTERVAL TIMEOUT HEALTHY-THRESHOLD UNHEALTHY-THRESHOLD HEALTH-CHECK TCP:8443 30 3 2 2
-
Use the elb-register-instances-with-lb command as in the following example.
PROMPT> elb-register-instances-with-lb MyLoadBalancer --headers --instances i-4f8cf126, i-0bb7ca62
Elastic Load Balancing returns the following:
INSTANCE INSTANCE-ID INSTANCE i-4f8cf126 INSTANCE i-0bb7ca62
Give Us Your Feedback
Your input is important to us to help make our documentation helpful and easy to use. Please take a minute to give us your feedback on how well we were able to help you use Elastic Load Balancing. Just click this feedback link. Thank you.