Sam.A.
Sam.A.

Reputation: 3

AWS Cloudfront drops custom domain name and redirects to Elastic Beanstalk

I have an elastic beanstalk environment with CloudFront serving SSL (ASP.Net MVC). CloudFront has a custom domain name. Everything works fine until the user's session cookie expires or the user tries to access a secured area without logging in and is redirected to the login page. When either of these two things happens, the user is somehow redirected to the actual elastic beanstalk environment and it also drops SSL, so if the user doesn't notice they'll be sending their login credentials without SSL. For example, if the user accesses https://custom.domain.com/admin without being logged in they get redirected to http://aws.elasticbeanstalkcontainer.com, same for session expiration. It worked fine on IIS10 before migrating to AWS. It seems that when EC2 sends the redirect back somehow CloudFront is missing it and not changing it to the custom domain name. Any help will be greatly appreciated. Thanks in advance.

Upvotes: 0

Views: 554

Answers (1)

Mark B
Mark B

Reputation: 200998

It is not CloudFront's job to monitor for redirect responses coming from your server and rewrite them with a different domain name. That's not something it does. You have to configure your application running on Elastic Beanstalk to be aware of the correct domain name it should use when it sends redirect responses back to the client.

Upvotes: 3

Related Questions