I'd like to ask for your help how to setup routing properly for a Cakephp web application on AWS. I got Cakephp running on AWS Elastic Beanstalk, using PHP configuration, and then I set an A record for my domain (e.g. foo.com) linking to Cloudfront CDN that was linked to the default ELB of Beanstalk. Everything was working fine, until I found out all redirections handled by Cakephp will redirect to the default public DNS of ELB (elb-abc123.elb.amazonaws.com/page/) instead of foo.com/page/. I know there's something called CName for elb, but I couldn't get it working (http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/using-domain-names-with-elb.html?). And I'm not sure if this is something with .htaccess.
Here's the route 53 setting of my domain:
foo.com. A ALIAS examplecode.cloudfront.net (examplecode...)
www.foo.com. A ALIAS examplecode.cloudfront.net (examplecode...)
And CouldFront settings:
Alternative Domain Names (CName): foo.com, www.foo.com
Okay, and here's an example of what I'm facing:
Schema: client->cloudfront->elb(beanstalk)->EC2
1. Everything works fine when A client type foo.com or www.foo.com in his/her browser.
2. The Cakephp asks for login when client is attempting to request a secure page foo.com/account/index (e.g. account page), so the redirection is handled by cakephp controller: $this->redirect(array('controller' => 'secure', 'action' => 'login'));.
3. The expecting landing url should be foo.com/secure/login/ bur what turns out is elb-abc123.elb.amazonaws.com/secure/login.
Can someone help me, thanks.