Hey everyone! I'm dealing with an issue where my ECS Fargate API, which is in a private subnet and exposed to the internet via APIGateway, VPC link, and NLB, is returning a 302 redirect that points to the internal NLB address. This means that when the redirect occurs, it tries to access my NLB in the private subnet and fails. I'm hoping to modify the redirect headers so that they point to the public DNS instead. Any ideas on what I might be missing? This has been really frustrating!
2 Answers
You can’t redirect public users to a private API endpoint since it won’t work. If the private endpoint needs to be accessible from the public, consider redirecting to a publicly available reverse proxy that can handle your API requests.
The reason your app is generating those redirects using the internal NLB hostname is because that’s what it identifies. To fix this, you should utilize the original host from the incoming request. Check out the X-Forwarded-Host header instead, and configure your application to trust proxy headers, which should allow the redirects to use the public URL.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically