[英]AWS ELB or Domain url redirects to EC2 instance public DNS
I am new to AWS and trying to map domain(registered in Godaddy) to AWS instance, here is what I have tried:我是 AWS 的新手,并试图将域(在 Godaddy 中注册)映射到 AWS 实例,这是我尝试过的:
Both www.example.com and test.example.com redirects to EC2 instance public DNS( http://ec2-52-11-xxx-xxx.us-west-2.compute.amazonaws.com/ ) If I hit ELB url(test-elb-34243545.us-west-2.elb.amazonaws.com) directly that also redirects to EC2 instance public DNS( http://ec2-52-11-xxx-xxx.us-west-2.compute.amazonaws.com/ ) www.example.com 和 test.example.com 都重定向到 EC2 实例公共 DNS( http://ec2-52-11-xxx-xxx.us-west-2.compute.amazonaws.com/ ) 如果我点击 ELB url(test-elb-34243545.us-west-2.elb.amazonaws.com) 也重定向到 EC2 实例公共 DNS( http://ec2-52-11-xxx-xxx.us-west-2. compute.amazonaws.com/ )
With redirect I mean url changes in address bar and also Chrome console shows 302 redirect.重定向是指地址栏中的 url 更改,Chrome 控制台也显示 302 重定向。
I don't want url to change in address bar.我不希望 url 在地址栏中更改。 Not sure what I am doing wrong, any help would be appreciated.
不知道我做错了什么,任何帮助将不胜感激。
Thanks in advance!提前致谢!
If you want traffic to go via the ELBs (this is a good thing) and not direct to the EC2 instance underneath then you don't need your elastic IP.如果您希望流量通过 ELB(这是一件好事)而不是直接到达下面的 EC2 实例,那么您不需要弹性 IP。
Instead create a CNAME in your Route53 Hosted Zone for www.example.com
that points to the ELB name (which will look like ${load_balancer_name}-${account_id}.${region}.elb.amazonaws.com
).而是在您的 Route53 托管区域中为
www.example.com
创建一个 CNAME,指向 ELB 名称(看起来像${load_balancer_name}-${account_id}.${region}.elb.amazonaws.com
)。
Now when you go to www.example.com
you will hit the ELB which will then load balance traffic to any attached EC2 instances underneath it.现在,当您访问
www.example.com
您将访问 ELB,然后将流量负载均衡到其下的任何附加 EC2 实例。 You can also leave the EC2 instances with purely private IP addresses so it's impossible to hit the EC2 instance directly without going through the ELB.您还可以将 EC2 实例保留为纯私有 IP 地址,这样不通过 ELB 就不可能直接访问 EC2 实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.