How to Redirect ECS API Traffic to a Public DNS Instead of Internal NLB?

0
12
Asked By TechiePal123 On

I'm struggling with a redirect issue in my ECS Fargate API setup. My API is in a private subnet but accessible from the internet through a setup involving API Gateway, VPC link, and Network Load Balancer (NLB). Everything works smoothly until my ECS API throws a 3xx redirect, which includes the NLB's internal DNS in the location header. This leads to a failure when the redirect tries to access the NLB from the private subnet. I need some help figuring out how to change the redirect headers so that they point to the public DNS instead of the internal one. What am I missing? Thanks, this is quite frustrating!

1 Answer

Answered By CodeWizard99 On

It sounds like the main problem is that your API is trying to redirect users to an internal endpoint, which definitely won't work. You can't redirect public users to a private API. Instead, consider setting up a publicly accessible reverse proxy that can serve your API. That way, your redirects would point to the public URL instead of the internal one.

TechiePal123 -

Thanks for the insight! Just to clarify, I want the redirect to go to the public DNS, but the NLB response header is automatically returning the internal DNS. How can I tweak the redirect header in AWS to ensure it points to the public DNS?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.