AWS ALB redirection issue; http -> https
If you’re using AWS ALB (application load balancer) and your website is running on https only, you might need to redirect all http traffics to https.
I had …
- curl -I http://example.com → https://example.com : Not working; get 204 (“HTTP/1.1 204 No Content”)
- curl -I http://www.example.com → https://example.com : working; get (“HTTP/1.1 301 Moved Permanently”)
- http://example.com →https://example.com on Browsers(but some of users were not.)
- My nginx configuration was quite correct about redirection(80 -> 443)
- ALB had 2 listeners as below


After digging a little bit… the https target group passed a http request as https(443 port) to nginx(Instance) and nginx served(skip server:80 configuration) as https even though it was a http request…. I switched from ELB to ALB. It’s my biggest mistake ever. 🤣

Anyway.. long story short;
There is the instance port in ELB configuration but for ALB is not. So if you want to redirect http to https correctly, you should create another target group for http then add the http target group to your ALB listener as 80 port.


All behaviors are working as expected now.
Updated — Just in case someone who is interested in another solution.
