在Amazon Route53中设置基于DNS的URL转发 [英] Set up DNS based URL forwarding in Amazon Route53

查看:1896
本文介绍了在Amazon Route53中设置基于DNS的URL转发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Amazon Route53中设置转发。我最后的DNS服务(Nettica)允许我将请求路由到aws.example.com到https://myaccount.signin.aws.amazon.com/console/。



Route53支持此功能?



Nettica如何实现?是否插入特殊的A,CNAME,PTR或TXT记录?

解决方案

Saurav描述的问题,但是我真的需要找到除路由53和S3之外不需要任何其他操作的解决方案。我创建了一个如何指导我的博客,详细说明了我做了什么。



这是我想出来的。






目标



仅使用Amazon S3中提供的工具和Amazon Route 53,创建一个自动转发。一种奖励技术(不在此处)转发到目标主机的特定页面,例如 http://redirect-destination.com/console/special-page.html 。如果您需要此功能,请阅读< ReplaceKeyWith> 元素。






步骤4:记录重定向池的端点





记下Amazon自动为此存储桶创建的静态网站托管端点。您将需要这个以备以后,因此请突出显示整个网址,然后将其复制并粘贴到记事本。



注意!此时您实际上可以点击此链接检查您的重定向规则是否输入正确,但要小心!这就是为什么...



假设您在重定向中的< Hostname> 标签内输入了错误的值规则。也许你不小心输入了 myaccount.amazon.com ,而不是 myaccount.signin.aws.amazon.com 。如果您点击链接来测试端点URL,AWS将很乐意将您的浏览器重定向到错误的地址!



注意到您的错误后,您可能会编辑<$ c您的重定向规则中的$ c><主机名> 以修复错误。不幸的是,当您尝试再次点击该链接时,最有可能会被重定向到错误的地址!即使您修改了< Hostname> 条目,您的浏览器将缓存上一个(不正确的!)条目。这是因为我们使用HTTP 301(永久)重定向,Chrome和Firefox等浏览器会默认缓存。



如果将端点URL复制并粘贴到一个不同的浏览器(或清除当前的缓存),您将有机会看到更新的< Hostname> 条目是否正确。 / p>

为了安全起见,如果要测试您的端点网址和重定向规则,您应该在Chrome中打开私人浏览会话,如隐身模式。复制,粘贴和测试无痕模式下的端点网址,任何缓存的信息将在您关闭会话后消失。






步骤5:打开Route53管理控制台并转到托管区域的记录集(域名)




  1. 选择您在创建存储桶时使用的托管区域(域名)。因为我命名我的桶url-redirect-example.vivekmchawla.com,我要选择vivekmchawla.com托管区。

  2. 点击转到记录集按钮






步骤6:点击创建记录集按钮





点击创建记录集将打开Route53管理控制台右侧的创建记录集窗口。






步骤7:创建CNAME记录集




  1. 在名称字段中输入URL的主机名部分当你命名你的S3桶时使用它。 URL的主机名部分是托管区域名称的左侧的所有内容。我命名我的S3桶url-redirect-example.vivekmchawla.com,我的托管区是vivekmchawla.com,所以我需要输入的主机名部分是url-redirect-example。


  2. 为此记录集的类型选择CNAME - 规范名称。


  3. 粘贴在步骤3中创建的S3存储区的端点URL。


  4. 单击创建记录集按钮。假设没有错误,您现在可以在托管区域的记录集列表中看到新的CNAME记录。







步骤8:测试您的新网址重定向



打开一个新的浏览器标签,然后输入URL我们刚刚成立。对我来说,这是

  • 配置网站托管Bucket

  • < a href =http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/R53Example.html =noreferrer>创建使用路由53的域

  • 创建,更改和删除资源记录



  • 干杯!


    I'm trying to setup forwarding in Amazon Route53. My last DNS service (Nettica) allowed me to route requests to "aws.example.com" to "https://myaccount.signin.aws.amazon.com/console/".

    Is this functionality supported by Route53?

    How does Nettica achieve this? Does it insert a special A, CNAME, PTR, or TXT record(s)?

    解决方案

    I was running into the exact same problem that Saurav described, but I really needed to find a solution that did not require anything other than Route 53 and S3. I created a how-to guide for my blog detailing what I did.

    Here is what I came up with.


    Objective

    Using only the tools available in Amazon S3 and Amazon Route 53, create a URL Redirect that automatically forwards http://url-redirect-example.vivekmchawla.com to the AWS Console sign-in page aliased to "MyAccount", located at https://myaccount.signin.aws.amazon.com/console/ .

    This guide will teach you set up URL forwarding to any URL, not just ones from Amazon. You will learn how to set up forwarding to specific folders (like "/console" in my example), and how to change the protocol of the redirect from HTTP to HTTPS (or vice versa).


    Step One: Create Your S3 Bucket

    Open the S3 management console and click "Create Bucket".


    Step Two: Name Your S3 Bucket

    1. Choose a Bucket Name. This step is really important! You must name the bucket EXACTLY the same as the URL you want to set up for forwarding. For this guide, I'll use the name "url-redirect-example.vivekmchawla.com".

    2. Select whatever region works best for you. If you don't know, keep the default.

    3. Don't worry about setting up logging. Just click the "Create" button when you're ready.


    Step 3: Enable Static Website Hosting and Specify Routing Rules

    1. In the properties window, open the settings for "Static Website Hosting".
    2. Select the option to "Enable website hosting".
    3. Enter a value for the "Index Document". This object (document) will never be served by S3, and you never have to upload it. Just use any name you want.
    4. Open the settings for "Edit Redirection Rules".
    5. Paste the following XML snippet in it's entirety.

      <RoutingRules>
        <RoutingRule>
          <Redirect>
            <Protocol>https</Protocol>
            <HostName>myaccount.signin.aws.amazon.com</HostName>
            <ReplaceKeyPrefixWith>console/</ReplaceKeyPrefixWith>
            <HttpRedirectCode>301</HttpRedirectCode>
          </Redirect>
        </RoutingRule>
      </RoutingRules>
      

    If you're curious about what the above XML is doing, visit the AWM Documentation for "Syntax for Specifying Routing Rules". A bonus technique (not covered here) is forwarding to specific pages at the destination host, for example http://redirect-destination.com/console/special-page.html. Read about the <ReplaceKeyWith> element if you need this functionality.


    Step 4: Make Note of Your Redirect Bucket's "Endpoint"

    Make note of the Static Website Hosting "endpoint" that Amazon automatically created for this bucket. You'll need this for later, so highlight the entire URL, then copy and paste it to notepad.

    CAUTION! At this point you can actually click this link to check to see if your Redirection Rules were entered correctly, but be careful! Here's why...

    Let's say you entered the wrong value inside the <Hostname> tags in your Redirection Rules. Maybe you accidentally typed myaccount.amazon.com, instead of myaccount.signin.aws.amazon.com. If you click the link to test the Endpoint URL, AWS will happily redirect your browser to the wrong address!

    After noticing your mistake, you will probably edit the <Hostname> in your Redirection Rules to fix the error. Unfortunately, when you try to click the link again, you'll most likely end up being redirected back to the wrong address! Even though you fixed the <Hostname> entry, your browser is caching the previous (incorrect!) entry. This happens because we're using an HTTP 301 (permanent) redirect, which browsers like Chrome and Firefox will cache by default.

    If you copy and paste the Endpoint URL to a different browser (or clear the cache in your current one), you'll get another chance to see if your updated <Hostname> entry is finally the correct one.

    To be safe, if you want to test your Endpoint URL and Redirect Rules, you should open a private browsing session, like "Incognito Mode" in Chrome. Copy, paste, and test the Endpoint URL in Incognito Mode and anything cached will go away once you close the session.


    Step 5: Open the Route53 Management Console and Go To the Record Sets for Your Hosted Zone (Domain Name)

    1. Select the Hosted Zone (domain name) that you used when you created your bucket. Since I named my bucket "url-redirect-example.vivekmchawla.com", I'm going to select the vivekmchawla.com Hosted Zone.
    2. Click on the "Go to Record Sets" button.


    Step 6: Click the "Create Record Set" Button

    Clicking "Create Record Set" will open up the Create Record Set window on the right side of the Route53 Management Console.


    Step 7: Create a CNAME Record Set

    1. In the Name field, enter the hostname portion of the URL that you used when naming your S3 bucket. The "hostname portion" of the URL is everything to the LEFT of your Hosted Zone's name. I named my S3 bucket "url-redirect-example.vivekmchawla.com", and my Hosted Zone is "vivekmchawla.com", so the hostname portion I need to enter is "url-redirect-example".

    2. Select "CNAME - Canonical name" for the Type of this Record Set.

    3. For the Value, paste in the Endpoint URL of the S3 bucket we created back in Step 3.

    4. Click the "Create Record Set" button. Assuming there are no errors, you'll now be able to see a new CNAME record in your Hosted Zone's list of Record Sets.


    Step 8: Test Your New URL Redirect

    Open up a new browser tab and type in the URL that we just set up. For me, that's http://url-redirect-example.vivekmchawla.com. If everything worked right, you should be sent directly to an AWS sign-in page.

    Because we used the myaccount.signin.aws.amazon.com alias as our redirect's destination URL, Amazon knows exactly which account we're trying to access, and takes us directly there. This can be very handy if you want to give a short, clean, branded AWS login link to employees or contractors.


    Conclusions

    I personally love the various AWS services, but if you've decided to migrate DNS management to Amazon Route 53, the lack of easy URL forwarding can be frustrating. I hope this guide helped make setting up URL forwarding for your Hosted Zones a bit easier.

    If you'd like to learn more, please take a look at the following pages from the AWS Documentation site.

    Cheers!

    这篇关于在Amazon Route53中设置基于DNS的URL转发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆