Set specific domain for ALB stickiness cookie

1

I need to set the domain attribute for the ALB stickiness cookie so that session stickiness behaves the same across two subdomains. For example, for the domains foo.example.com and bar.example.com, I'd want the stickiness cookies to have domain=.example.com. However, I don't see any way to configure that for load-balancer-generated cookies. I also tried using an application cookie that has its domain set in the hope that the ALB would propagate the domain to the AWSALBAPP-* cookies, but that doesn't work either.

asked 6 months ago84 views
1 Answer
1

I had a chat about this with AWS Support recently.

At the time of writing this, it was not supported, but they had a feature request for it, with unknown ETA.

A workaround they suggested was to use CloudFront in front of ALB and rewrite the cookies. I have not tried it myself, but if you're desperate, might be worth a try.

Maybe API Gateway could also be used to rewrite the set-cookie header for the response received from ALB (instead of CloudFront), though somewhere I've seen that API Gateway had some issues with multiple headers with the same name.

--

Our use case was that our web app is hosted at frontend-app.company.com but our backend is exposed as an ALB under service.api.company.com domain. When ALB sets cookies, they do not specify the domain name, therefore they get set on the frontend-app.company.com domain, and don't get sent with the next request to the service.api.company.com (making stickiness not work).

grimsa
answered 14 days ago
  • Thanks for letting me know about your support chat with them! It's disappointing that there's no ETA for this feature. We've since made plans to put our entire site behind Cloudflare and use workers to rewrite the cookies as they're coming out of AWS. AWS, if you're reading this, it would be so nice to be able to do this natively 🙏

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions