Other Articles

Load Balancer – Redirect HTTP Traffic to HTTPS

Secure Configuration Checks > AWS

This check ensures that every HTTP listener of an Application Load Balancer redirects clients to HTTPS. Without a redirect, requests sent over HTTP are served in clear text. Anyone on the network path can read or change them.

Check Details

  • Resource: Application Load Balancer listener
  • Check: Redirect load balancer HTTP traffic to HTTPS (HttpRedirectsToHttps)
  • Risk: Credentials, session cookies and personal data travel unencrypted and can be intercepted or modified

Remediation via AWS Console

  1. Open the Amazon EC2 console and select Load Balancers under Load Balancing.

    Amazon EC2 Console
  2. Select the affected Application Load Balancer and open Listeners and rules.

  3. Verify that an HTTPS listener exists on port 443. If not, click Add listener, select HTTPS, configure the target group and ACM certificate, and add the listener.

    Load balancer listeners and rules tab
  4. Select the HTTP listener and open its Rules tab. Select the Default rule, then choose Actions > Edit rule.

  5. Under Default action, choose Redirect to URL. Set the protocol to HTTPS, port to 443, and status code to HTTP 301.

    Configure HTTP to HTTPS redirect
  6. Choose Save changes. Repeat for every HTTP listener on each affected Application Load Balancer.

Note: Review non-default HTTP listener rules too. Any rule that forwards traffic instead of redirecting it may allow HTTP requests to bypass the redirect.

Remediation via AWS CLI

  1. Log in to the AWS Management Console and click the CloudShell icon (>_) in the top-right corner.

    AWS CloudShell
  2. List the HTTP listeners that do not redirect to HTTPS:

    for arn in $(aws elbv2 describe-load-balancers \
      --query 'LoadBalancers[?Type==`application`].LoadBalancerArn' \
      --output text); do
      aws elbv2 describe-listeners --load-balancer-arn "$arn" --output json | \
      jq -r '.Listeners[]
        | select(.Protocol == "HTTP")
        | select(any(.DefaultActions[]; .Type == "redirect" and .RedirectConfig.Protocol == "HTTPS") | not)
        | .ListenerArn'
    done
    

    The command covers one region. Add --region <region> to each aws command to check another.

  3. If the load balancer has no HTTPS listener yet, create one. Skip this step if it already has one:

    aws elbv2 create-listener \
    --load-balancer-arn <load-balancer-arn> \
    --protocol HTTPS \
    --port 443 \
    --certificates CertificateArn=<acm-certificate-arn> \
    --ssl-policy ELBSecurityPolicy-TLS13-1-2-2021-06 \
    --default-actions Type=forward,TargetGroupArn=<target-group-arn>
    
  4. Change the default action of the HTTP listener to a redirect:

    aws elbv2 modify-listener \
    --listener-arn <http-listener-arn> \
    --default-actions '[{"Type":"redirect","RedirectConfig":{"Protocol":"HTTPS","Port":"443","StatusCode":"HTTP_301"}}]'
    

    The host, path and query of the request are kept by default, so http://example.com/page?id=1 becomes https://example.com/page?id=1.

  5. Verify the listener:

    aws elbv2 describe-listeners \
    --load-balancer-arn <load-balancer-arn> \
    --query "Listeners[?Protocol=='HTTP'].[ListenerArn,DefaultActions[0].Type,DefaultActions[0].RedirectConfig.Protocol]" \
    --output table
    

    The action type must be redirect and the protocol HTTPS. You can also test with curl -I http://<load-balancer-dns-name>. The response must be 301 with a Location header that starts with https://.

Replace <load-balancer-arn> with the ARN of the Application Load Balancer. Replace <http-listener-arn> with the ARN of the HTTP listener that step 2 lists. Replace <acm-certificate-arn> and <target-group-arn> with your certificate and target group. Repeat steps 4 and 5 for each listener that step 2 lists.

Updated on 04 November, 2026