簡體   English   中英

AWS:如何為自定義域名配置 Cloudfront

[英]AWS: How to configure Cloudfront for Custom Domain Names

我的設置:

API 網關- 10 個 API (api1, api2,...),全部映射到一個自定義域名 (api.xxx.com)

Route53 - api.xxx.com 指向我的 Cloudfront 分布

Cloudfront - 已創建分發,api.xxx.com 設置為 CNAME

我需要知道的- 我想將此 Cloudfront 的 Origin 設置為此自定義域名,因此我可以調用諸如api.xxx.com/api1/endpointapi.xxx.com/api2/endpoint 之類的 API。 但是怎么做? I used API Gateway Name of my api.xxx.com Custom Domain name (xxxxxxx.execute-api.us-east-1.amazonaws.com) for default behaviour Origin name and assumed that requests to all 10 APIs will be routed correctly,但它沒有發生,

什么有效:我使用 api1 的 Invoke Url 創建了 Origin 名稱並將其分配給默認行為。 所以現在,當我調用“https://api.xxx.com/endpoint”時,會調用 api1。 這是有道理的,但問題是 -我需要 API 的路徑成為 url 的一部分,例如“https://api.xxx.com/api1/endpoint”,以便我可以區分它們。

什么不起作用:但我需要在發行版中設置幾個 API,以便我可以將它們稱為“https://api.xxx.com/api1/endpoint”等。 And if I use Invoke URL as the Origin name for the API, I cannot attach this api name also to the URL, that returns 403. I was hoping that if I used "API Gateway domain name" of "Custom Domain Names" (after所有,它的格式為 xxxxx.execute-api.us-east-1.amazonaws.com),然后我可以在 URL 中使用 API,但這不起作用。 我什至不能使用這個“API 網關域名”通過 Postman 調用單個 api。 有人可以建議我怎么做嗎? 如何配置 Cloudfront 以便它可以調用各種 API 並在 url 中使用它們的路由?

我的設置與你的有點不同,但似乎我們想要實現相同的目標。

我有四個通過雲端提供服務的 S3 存儲桶。 一桶是根網站; 其他 3 個存儲桶包含 3 個不同的管理面板

對於每個 s3 存儲桶,我創建了一個單獨的來源; 我相信您應該為每個單獨的 api 創建一個原點。

我為每個原點組添加了兩個路徑模式; 我相信對於您的 api,每個 api 可以有一個模式。 路徑模式可能看起來像 /api1/* ,它指向 api1 的原點

不確定您是否嘗試為所有 api 添加來源; 請讓我知道這是否有幫助。

終於找到了一個解決方案,在這個討論線程中有更詳細的描述。 我的問題是我試圖直接從 Cloudfront 使用指向自定義域名 (xxxxxxxxxxxx.execute-api.us-east-1.amazonaws.com) 的鏈接,但我應該使用“好”、可讀的地址作為源名稱和在 Route53 中進行重定向

工作設置:

  1. 在API網關中,創建自定義域名regional-api.xxx.com,端點類型Regional(xxxxxxxxxxxx.execute-api.us-east-1.amazonaws.com)。
  2. 在Route53中,A和AAAA記錄mapregional-api.xxx.com到Region endpoint目標域名。
  3. 創建的 Cloudfront 分發使用 region-api.xxx.com 作為源域名,使用 api.xxx.com 作為 CNAME。
  4. 在Route53中,A和AAAA將map api.xxx.com記錄到新創建的CF分布的域名中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM