Redirect HTTP to HTTPS

Intermediate
9 min read
Updated: Nov 2026
5 examples
ALB / TLS / ACM

Definition and Usage

After you attach an ACM certificate to an HTTPS listener on your Application Load Balancer, you still receive plain HTTP on port 80 unless you close or redirect it. This guide edits the HTTP listener default rule so browsers receive a redirect to HTTPS.

What does an ALB HTTP redirect do?

The ALB answers http:// with a 301 or 302 and a Location: header pointing at https:// on the same host and path. Clients then load TLS on port 443.

When should you configure this?

After the ACM walkthrough validates DNS and your HTTPS listener is healthy. Complete creating an ALB first if you do not have listeners yet.

Why use placeholders?

Prefer #{host}, #{path}, and #{query} instead of hardcoding one marketing domain so apex and subdomains each upgrade to HTTPS for themselves.

CDN and HSTS

If viewers hit CloudFront first, enforce HTTPS at the CDN as well. After redirects are stable, consider HSTS so browsers prefer HTTPS on future visits.

Keep port 80 for upgrades.

Deleting the HTTP listener makes typed http:// URLs fail instead of redirecting. A redirect on 80 is the usual public-site pattern.

Do not hardcode a single apex host.

Hardcoding one hostname can send all subdomains to the wrong site. Use ALB placeholders for host, path, and query.

Next after redirects work.

Normalize apex vs www in Route 53 or the www redirect guide.

Core Concepts

Terms you will use while configuring the redirect:

ConceptMeaning
HTTP listenerALB process on port 80 that receives plain HTTP
HTTPS listenerALB process on port 443 with an ACM certificate
Redirect actionListener rule that returns 301/302 instead of forwarding
#{host}Placeholder that reuses the incoming Host header
#{path} / #{query}Placeholders that preserve path and query string
301Permanent redirect (canonical HTTPS for caches and SEO)
302Temporary redirect while you are still validating TLS
Security groupMust allow inbound TCP 80 and 443 to the ALB

Prerequisites

Have these ready before you edit the listener:

  • An AWS account with access to EC2 (load balancers) and usually Route 53.
  • An internet-facing ALB with an HTTP:80 listener you can edit.
  • A public ACM certificate on an HTTPS:443 listener that forwards to a healthy target group.

Examples

Edit the HTTP:80 default rule to redirect to HTTPS:443, confirm security groups, then test with a browser or curl.

Example 1 — Open the HTTP Listener

Start from the ALB Listeners and rules tab.

  1. Open the EC2 console.
  2. Open Load Balancers, select your ALB, then the Listeners and rules tab.
  3. Select the HTTP:80 listener.
ALB listeners and rules tab with HTTP port 80 listener
Elastic Load Balancing

How It Works

  1. Port 80 is where browsers send plain http:// requests.
  2. Listeners and rules control forward vs redirect vs fixed responses.
  3. HTTPS:443 should already exist with ACM before you cut over redirects.
  4. Console labels vary—use the screenshots as a visual anchor.

Example 2 — Edit the Default Rule

Open the catch-all rule that currently forwards HTTP traffic.

  1. Under Rules, open the default rule (or the catch-all you use for plain HTTP).
  2. Choose Actions → Edit rule (wording may read Edit depending on console version).
Edit default rule on HTTP listener port 80
Elastic Load Balancing

How It Works

  1. The default rule runs when no higher-priority host/path rule matches.
  2. Editing here changes what every unmatched HTTP request does.
  3. Leave HTTPS rules alone while you only change the HTTP listener.
  4. Path-specific HTTP rules may need the same redirect if you use them.

Example 3 — Redirect to HTTPS with Placeholders

Switch the action from forward to redirect and preserve host, path, and query.

  1. Change the default action from Forward to target group to Redirect to URL.
  2. Set Protocol to HTTPS and Port to 443.
  3. Choose a status code (commonly 301 permanent once you are sure; use 302 while testing).
  4. Prefer #{host} for the host, #{path} for the path, and #{query} for the query string.
  5. Save changes and wait for the listener state to return to active.
ALB rule editor redirect to HTTPS listener details
Elastic Load Balancing
ALB redirect URL configuration with host path query parts
Elastic Load Balancing

How It Works

  1. Redirect returns a status + Location instead of proxying to targets.
  2. #{host} keeps each hostname on itself across the upgrade.
  3. 301 is for production cutovers; 302 is safer during dry runs.
  4. HTTPS must forward to targets—never redirect 443 back to HTTP or you will loop.

Example 4 — Confirm ALB Security Groups

Clients need both 80 (redirect) and 443 (TLS site).

  1. Open EC2 → Load Balancers, select your ALB, and copy the security group IDs from the Description tab.
  2. Open EC2 → Security Groups, select each ALB security group.
  3. Under Inbound rules, ensure HTTP (80) and HTTPS (443) are permitted from the sources you intend (often 0.0.0.0/0 for public sites; tighten later with WAF or allow lists).

How It Works

  1. Port 80 must stay open so clients can receive the redirect response.
  2. Port 443 must stay open so the upgraded HTTPS request succeeds.
  3. Target security groups still need to allow the ALB on the app port.
  4. Public 0.0.0.0/0 is common for websites; lock down admin-only ALBs.

Example 5 — Test the Redirect

Verify status, Location header, and a valid certificate.

  1. Open a browser or run curl -I http://your-domain.example.
  2. Confirm a 301 or 302 with Location: pointing at https:// on the same host and path.
  3. Load the HTTPS URL and verify the certificate is valid for your hostname.
Terminal
curl -I http://your-domain.example
Browser address bar showing HTTPS for the site
Browser

How It Works

  1. curl -I shows status and headers without downloading the body.
  2. Location must use https:// and the expected host/path.
  3. Certificate errors mean ACM/DNS issues on 443, not the redirect itself.
  4. Next: apex/www cleanup in Route 53 or www redirection.

Edge Cases & Pitfalls

Most redirect bugs are hardcoded hosts, missing SG rules, or HTTPS looping back to HTTP.

host

Hardcoded apex in the redirect

Subdomains jump to the wrong site. Use #{host} so each hostname upgrades to itself.

loop

Redirect loop

HTTPS listener must forward to targets, not redirect back to HTTP. Check both listeners with curl.

sg

Port 80 closed after TLS

Clients never receive the redirect if HTTP is blocked. Keep 80 open for public sites that rely on upgrades.

cert

Redirect works, HTTPS fails

ACM certificate, hostname coverage, or target health on 443 is wrong. Fix TLS before relying on 301s.

cdn

CloudFront in front

Viewer protocol policy may already force HTTPS. Align CDN and ALB so origins and viewers do not fight.

cache

Browsers cache a 301

Use 302 while testing. After a mistaken 301, clear cache or use a private window to retest.

Key Takeaways

  • HTTP:80 default action becomes a redirect to HTTPS:443 once TLS is healthy.
  • Placeholders for host, path, and query keep every hostname correct.
  • Security groups: allow both 80 and 443 on the ALB.
  • Test with curl -I, then lock in 301 when HTTPS looks good.

One line: HTTP:80 redirects to HTTPS:443 with #{host}/#{path}, while 443 keeps forwarding.

Frequently Asked Questions

Add or edit a rule on the HTTP listener (port 80) so the default action is a redirect to HTTPS on port 443, using the host and path placeholders the ALB provides. Ensure an HTTPS listener exists with a valid certificate and that security groups allow inbound TCP 80 and 443 from clients.
301 Moved Permanently tells browsers and caches the HTTPS URL is canonical. 302 Found is temporary. Most production cutovers use 301 once you are confident the HTTPS site is correct.
Hardcoding a single hostname in the redirect can break subdomains or multiple alternate domain names on the same ALB. Using ALB placeholders such as #{host} and #{path} keeps each incoming hostname mapped to itself on HTTPS.
If you delete the HTTP listener, many clients that type http:// will fail instead of being upgraded. Keeping port 80 with a redirect is the usual pattern for public sites.
Yes. Ensure the HTTPS listener forwards to targets and does not redirect back to HTTP. Test with curl verbose output or browser devtools network panel when you change rules.
If viewers hit CloudFront first, you often terminate TLS and enforce HTTPS at the CDN, then connect to the origin over HTTPS. The ALB redirect pattern still matters for direct ALB access and for origins behind CloudFront when you allow HTTP from the CDN only.

Next: Route 53 DNS

Publish alias or CNAME records so clients reach your load balancer on both apex and www hostnames.

Amazon Route 53 →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful