如何将 53 路由到弹性豆茎

how to route 53 to elastic beanstalk

目前我已经使用 docker 平台和 运行 很好地创建了 elasticbeanstalk。

我的问题是: 我想通过路由 53 重定向将我的子域路由到我的弹性豆茎。 我已经转到 53 号公路并将我的子域 CNAME 更改为指向我的弹性豆茎。 我用 dig 命令检查:

;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8115
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;staging.mydomain.com.      IN  A

;; ANSWER SECTION:
staging.mydomain.com    145 IN  CNAME   myelasticbeanstalk.ap-southeast-1.elasticbeanstalk.com.
myelasticbeanstalk.ap-southeast-1.elasticbeanstalk.com. 36 IN A 175.xx.xx.xx
myelasticbeanstalk.ap-southeast-1.elasticbeanstalk.com. 36 IN A 52.xx.xx.xx

;; Query time: 38 msec
;; SERVER: xx.xx.xx.xx
;; WHEN: Sat Mar 19 10:36:34 
;; MSG SIZE  rcvd: 140

但是当我通过浏览器访问 staging.mydomain.com 时它不起作用。

奇怪的是,我可以通过浏览器直接访问 URL myelasticbeanstalk.ap-southeast-1.elasticbeanstalk.com

所以我需要帮助如何解决这个问题? 我只需要通过我的子域访问 myelasticbeanstalk。

谢谢大家

由于您的 URL 包含区域名称 ap-southeast-1,您需要使用 Route 53 别名。

If the domain name includes the Region You can create an alias record. An alias record is specific to Route 53 and has two significant advantages over CNAME records:

You can create alias records for the root domain name or for subdomains. For example, if your domain name is example.com, you can create a record that routes requests for example.com or for acme.example.com to your Elastic Beanstalk environment.

Route 53 doesn't charge for requests that use an alias record to route traffic.

要为 Elastic beanstalk 创建别名,请参阅说明 here