Set up DNS based URL forwarding in Amazon Route53 [closed] - dns
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
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
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".
Select whatever region works best for you. If you don't know, keep the default.
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
In the properties window, open the settings for "Static Website Hosting".
Select the option to "Enable website hosting".
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.
Open the settings for "Edit Redirection Rules".
Paste the following XML snippet in its 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)
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.
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
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".
Select "CNAME - Canonical name" for the Type of this Record Set.
For the Value, paste in the Endpoint URL of the S3 bucket we created back in Step 3.
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.
Example: Setting Up a Static Website Using a Custom Domain
Configure a Bucket for Website Hosting
Creating a Domain that Uses Route 53
Creating, Changing, and Deleting Resource Records
The AWS support pointed a simpler solution. It's basically the same idea proposed by #Vivek M. Chawla, with a more simple implementation.
AWS S3:
Create a Bucket named with your full domain, like aws.example.com
On the bucket properties, select Redirect all requests to another host name and enter your URL:
https://myaccount.signin.aws.amazon.com/console/
AWS Route53:
Create a record set type A. Change Alias to Yes. Click on Alias
Target field and select the S3 bucket you created in the previous
step.
Reference: How to redirect domains using Amazon Web Services
AWS official documentation: Is there a way to redirect a domain to another domain using Amazon Route 53?
I was able to use nginx to handle the 301 redirect to the aws signin page.
Go to your nginx conf folder (in my case it's /etc/nginx/sites-available in which I create a symlink to /etc/nginx/sites-enabled for the enabled conf files).
Then add a redirect path
server {
listen 80;
server_name aws.example.com;
return 301 https://myaccount.signin.aws.amazon.com/console;
}
If you are using nginx, you will most likely have additional server blocks (virtualhosts in apache terminology) to handle your zone apex (example.com) or however you have it setup. Make sure that you have one of them set to be your default server.
server {
listen 80 default_server;
server_name example.com;
# rest of config ...
}
In Route 53, add an A record for aws.example.com and set the value to the same IP used for your zone apex.
Update
While my original answer below is still valid and might be helpful to understand the cause for DNS based URL forwarding not being available via Amazon Route 53 out of the box, I highly recommend checking out Vivek M. Chawla's utterly smart indirect solution via the meanwhile introduced Amazon S3 Support for Website Redirects and achieving a self contained server less and thus free solution within AWS only like so.
Implementing an automated solution to generate such redirects is left as an exercise for the reader, but please pay tribute to Vivek's epic answer by publishing your solution ;)
Original Answer
Nettica must be running a custom redirection solution for this, here is the problem:
You could create a CNAME alias like aws.example.com for myaccount.signin.aws.amazon.com, however, DNS provides no official support for aliasing a subdirectory like console in this example.
It's a pity that AWS doesn't appear to simply do this by default when hitting https://myaccount.signin.aws.amazon.com/ (I just tried), because it would solve you problem right away and make a lot of sense in the first place; besides, it should be pretty easy to configure on their end.
For that reason a few DNS providers have apparently implemented a custom solution to allow redirects to subdirectories; I venture the guess that they are basically facilitating a CNAME alias for a domain of their own and are redirecting again from there to the final destination via an immediate HTTP 3xx Redirection.
So to achieve the same result, you'd need to have a HTTP service running performing these redirects, which is not the simple solution one would hope for of course. Maybe/Hopefully someone can come up with a smarter approach still though.
If you're still having issues with the simple approach, creating an empty bucket then Redirect all requests to another host name under Static web hosting in properties via the console. Ensure that you have set 2 A records in route53, one for final-destination.com and one for redirect-to.final-destination.com. The settings for each of these will be identical, but the name will be different so it matches the names that you set for your buckets / URLs.
Related
Unable to map naked domain (non www) to Google Cloud Storage bucket
Good day, I am trying to host a static site on G Cloud Storage. I followed the documentation here https://cloud.google.com/storage/docs/hosting-static-website and all was successful. I purchased a domain from namecheap volunux.com and I named my bucket during creation as www.volunux.com after verifying the ownership in Search Console. I wasn't satisfied with the "Not secure" thingy, so I wanted HTTPS, I should have used Load balancer but I was looking for something cheap at the moment. So I opted for Cloudflare to get me a free SSL and all was fine but here is the problem. My site works at www.volunux.com, https://www.volunux.com but never works when it is: volunux.com, http://volunux.com, https://volunux.com For close to 24 hours since yesterday, I have been searching for solution to this problem all over the internet. Some suggested and said, one have to create two bucket in GCS to serve both www and non-www. Some, one have to create another bucket and in the web configuration, set the MainPageSuffix as https://www.volunux.com so that redirect will be perform. Some, one have to create a cname record to c.storage.googleapis.com which I did but didn't work. Some, one have to create an A record to set the IP to my hosting provider, I assume GCP but it didn't work either. Some, I have to create a page rule and redirect all request from volunux.com with or without protocol to https://www.volunux.com I think #1 would have worked but I have to maintained two separate buckets for one thing and #2, I don't know if it is standard practice but from #3 to #5. All efforts prove abortive. I have read through threads on Stackoverflow, CloudFlare community, personal blogs, all didn't work out for me. I have performed a URL Rewrites, 301 redirects from volunux.com/* to https://www.volunux.com/$1 but all efforts prove abortive based on the solutions I have found on the internet, I am confused at this stage because I don't know what to do. I am thinking of moving back to Github Pages using Jekyll or even to AWS S3 but I don't want to do that just yet. Somebody please help. Attached are the screenshot of configurations.
This is what I do: Set up the Google cloud storage bucket to the naked domain / non-www domain e.g. example.com Then use Cloudflare to set up CNAME at the naked domain to c.storage.googleapis.com which has CNAME flattening by default. Then add an A record to the 'www' subdomain to a private address such as '192.0.2.1' Then add a Cloudflare rule in 'Rules' that is a Forwarding URL with status code '301 - Permanent Redirect' from www.example.com/* to https://example.com/$1 This means only 1 bucket to the naked domain and if anyone tries to go to www.example.com it will rewrite to https://example.com. So always HTTPS as well, works great.
How to set alias correctly in Network Solutions CNAME to use Amazon s3 bucket?
I've create my s3 bucket with the same name as my site, awsmd.org I've enabled website content and can see the page at http://awsmd.org.s3.us-east-2.amazonaws.com/index.html also at https://s3.us-east-2.amazonaws.com/awsmd.org/index.html I have the domain previously registered (months ago) awsmd.org in Network solutions. I believe I have to update the CNAME records? I have made changes and current the display page looks like this. I think there may be a bug - that doublename stuff in the alias column is weird. However when I open up the detail page I see Is that set correctly there? Using http://awsmd.org/index.html I am currently seeing the aws under construction page, but I only recently (last hour) deleted the A records pointing to under construction pages Am I doing this right. Do I just need to wait for DNS propogation ? I see others have had issues using Network Solutions UI.
The typo was from how I (incorrectly) used the alias, you actually use # for the plain (no www) name, e.g. host.org and www for the www.host.org host It ends up showing as follows which seems odd for the plain # one but is apparently correct.
Cloud Service Custom Domain Redirection configuration
i am not sure whether this correct words to describe the problem, but i try my best to explain. Suppose i deployed a cloud service with A Name. now client ask me give me something good domain name rather than A.cloudapp.net, so according to need i given him fancy domain name A.myapp.com. After some time they thinks A is not a good name , give me B. so i change the deployment to B.cloudapp.net and then configured custom Domain Name as B.myapp.com. Client again comes as says my customer is still using A.myapp.com. Can you do something to redirect them to B.myapp.com. with message that it moved to another address. As i know i used only CNAME and ARecord on domain registrar . how can show a message over there. That this page is moved to other domain.
If A.myapp.com is no longer in the DNS records then the only way that it's still working is that the DNS propagation hasn't taken full effect yet. That can take even up to a few days. Once that happens then A.myapp.com should no longer resolve. This might also be working if you have a wildcard record for #.myapp.com pointing to the same A.cloudapp.net site. You can create the A.myapp.com DNS record (if it's not still there) and point it to the same cloudapp.net app again, but then in your cloud app look at the hostname as it comes it to the request. If it is A.myapp.com show them a specific page that reminds them this is now B.myapp.com and then redirect them.
Domain Mapping To Subdomain
Im running SAAS where customer signs up and a script installation takes place in a subdomain, i.e., subdomain.mydomain.com and starts using the site. Now I want to allow my customers to map their FULL domain eg. www.customerdomain.com to subdomain.mydomain.com, something like bloggers.com or wordpress does. How I can do this. I am using Linux dedicated server. Help would be greatly appreciated. I dont want URL masking or redirection.
I'm currently developing a project and have recently faced the exact same issue. Here's two ways you can go about solving it: Super-easy A little more tricky, but not impossible The first would be to allow domain mapping of subdomains (e.g. http://subdomain.example.com). This is dead simple for your users to setup. They would head over to their registrar and create a new CNAME record as follows: (name) subdomain.example.com -> (record) subdomain.yoursite.com Unlike changing A Records, this change only takes about 120 mins to fully propagate (compared with up to 72 hrs). If your users pay for the privilege of using the domain mapping feature (i.e. it's not made available to users on a free plan), then you could could store each user's custom subdomain in your database, then check against this (in .php) when they try to access your website via their custom subdomain. If they're allowed, do nothing, otherwise redirect them to an alternate url. So that's the easy one over and done with. Now for trickier option. If you have a dedicated IP address, or in your case a dedicated server, you can use the cPanel API to dynamically create A Records, this way users would be able to map their domain (rather just their subdomain) to your website. You would need to make the following A Record for your customer, together with getting them to update their domain's A Record with your dedicated IP address: Your server: (name) customersdomain.com -> (record) subdomain.yoursite.com Customer's registrar: www -> (record) [YOUR IP ADDRESS] I'm not going to detail the API process for you, but you can read through the documentation here: http://docs.cpanel.net/twiki/bin/view/SoftwareDevelopmentKit/ApiAuthentication Anyways, I hope this helps and that you have fun building your website! J
The (name) represents the custom domain belonging to your customer (e.g. customerdomain.com). The (record) would point to their subdomain on your SAAS site. So if I signed up to your website with a username of 'nike', you would use 'nike.yoursite.com'. J
Install the wordpress domain mapping plugin, obviously your wordpress installation is setup for Wordpress MU. Now the way I understand it you want to give your bloggers the opportunity to host their blog on their own personal domain while still hosting on your sever. Under "Domain Mapping" in "Settings" of "Network Administrator"(Super User). There is Domain Options: You want to check the User domain mapping page that's Option 3. This will allow your blog users to specify the domain of their personal site. One thing to remind them is that their DNS records should point to your web server.
Using DNS to redirect to another URL with a path [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered. Closed 3 years ago. Improve this question I'm trying to redirect a domain to another via DNS. I know that using IN CNAME it's posible. www.proof.com IN CNAME www.proof-two.com. What i need is a redirection with a path. When someone types www.proof.com, it should take them to to www.proof-two.com/path/index.htm I know it can be done using Web Server facilities, but I need DNS redirection. Is this possible?
No, what you ask is not possible. DNS is name resolution system and knows nothing about HTTP.
if you use AWS, a redirect like mail.foo.com --> mail.google.com/a/foo.com can be setup as follows: in s3, create an empty bucket "mail.foo.com" under Properties -> Static Website Hosting, set "redirect all requests to: mail.google.com/a/foo.com" in route53, create an A record "mail.foo.com" enable "alias", and set alias target to the "mail.foo.com" bucket not a pure DNS solution, but it works ;) But be aware of, the redirect skips all the URL parameters e.g.: ...?param1=value1¶m2=value2
I realize this is an old thread but FWIW, incase someone else is looking for a way to do this. While dns does not understand the path portion of the url, it will understand subdomains, so instead of: www.proof.com IN CNAME www.proof-two.com/path/index.htm You could use: www.proof.com IN CNAME proof.proof-two.com then go to wherever you host proof-two.com and set it to point proof.proof-two.com to www.proof-two.com/path/index.htm. ~ there's always more than one way to skin a cat
Some providers allow this but there are no "pure" DNS solutions since DNS doesn't know anything about the protocol you're using and redirects are a feature from HTTP. For OVH, see : https://docs.ovh.com/gb/en/domains/redirect-domain-name/ You will have to use the control panel to add your redirection. It will update your DNS zone accordingly. Let's consider you created a redirection from foo.bar.com to foo2.bar.com/path. OVH keeps the url paths and parameters. So if you try to access foo.bar.com/hello?foo=bar, you'll be redirected to foo2.bar.com/path/hello?foo=bar.
I have a personal project that might help you in solving this issue. It's an open source redirect solution that allows you to redirect your domain just changing your DNS settings. Link of the project: https://redirect.center/. To redirect www.proof.com to www.proof-two.com keeping the URL parameters, just set your www DNS entry on proof.com: www.proof.com IN CNAME www.proof-two.com.opts-uri.redirect.center.
Really it's easy with redirect.center If you want create a CNAME as : www.proof.com IN CNAME www.proof-two.com/path/index.htm using redirect.center your CNAME look as canonical mode as: www.proof.com IN CNAME www.proof-two.com.opts-slash.path.opts-slash.index.htm.redirect.center. Now if you want redirect to https website you can add this option: www.proof.com IN CNAME www.proof-two.com.opts-slash.path.opts-slash.index.htm.opts-https.redirect.center. Now you can create a CNAME with the canonical mode with slash in your destiny page.
To answer the original question, no, what you want is not possible using only DNS (like everyone has stated). In addition to everything mentioned already, another option is to use a URL redirection service. These types of services can enable you to configure many different types of URL redirects depending on your needs. For example: Forward a domain apex to a www. subdomain or vice versa Forward a collection of domain names to a single destination (useful for forwarding domain misspellings, old company names, etc.) Forward specific domain names to deeply linked pages (like what the OP wants) A service that does this is EasyRedir. Full disclosure: I developed EasyRedir. There are certainly other options out there though, so I encourage you to have a look around.
DNS won't redirect the path portion of a URL, so that won't be possible. Adding www.proof.com IN CNAME www.proof-two.com will direct access to www.proof.com to www.proof-two.com, where you will need to use web server config to direct users to the appropriate page.
A related work concluded all the below: Problem: http://a.com/p1/p2.html should go to http://B.com/p1/p2.html today, but later when configured manually/automatically, the same http://a.com/p1/p2.html should go to http://C.com/p1/p2.html Answers: DNS - converts name to IP address Though it can do a lot of redirects, always output is IP address DNS does not understand the path or protocol part of URL, understands domain part only, that is, a.com only is converted to IP address, so when you hit http://a.com/p1/p2.html may be converted to http://152.132.121.11/p1/p2.html if you configure wrong in DNS, then you will get 152.132.121.11 (not http://152.132.121.11/p1/p2.html), so you would get some 400s error (400, 403, etc.) Redirection - this is http://a.com/p1/p2.html can be converted to http://b.com/p1/p2.html All the methods like GET, POST can work, with if any headers and body, but there is a web server is involved, it could be point of failure, so scalability and availability will be key If you are on AWS, Route 53 -> API Gateway is possible though custom domains, internally using the Cloud front It is possible with Amazon Certification Manager, AWS Gateway custom domains & Route53, note the us-east-1 restriction on ACM Hope that helps someone
I will suppose you have this scenario: You have a unique webserver hosting various websites, each one is supposed to be presented by a separated domain: http://example.com/customer1/website/page1.html http://example.com/customer2/website/page2.html so, the page1.html should be served by www.customer1.com and so on. create a subdomain inside the example.com dns server (your webserver): customer1.example.com in your apache virtual server settings, map the subdomain to the directory that contain the web site for your customer #1, like this: <VirtualHost *:80> SetEnv PAGE_ID "customer1" ServerName customer1.example.com ServerAlias www.customer1.com DocumentRoot /your/local/path/webserver/customer1 </VirtualHost> please note the value for "ServerAlias", it is important for the next step- at this point, you should be able to navigate to your customer1 website by browsing to: customer1.example.com In the DNS settings for customer1.com you must make a CNAME record: CNAME=www LOCATION=customer1.example.com Now, you're enabled to use: www.customer1.com.
My solution to this problem was pretty simple and straight forward. All you need is an IIS server running inside the domain. Setup CNAME in DNS to point to the IIS server, using host names in IIS to resolve several sites on a single IIS server. I'm using the same IIS server to farm out a few sub domains to external sites. Then in IIS setup setup redirection for that site to go to your offsite site/path, in my case it was our hosted catalog that I wanted catalog.ourdomain.com to go to. From here all the tweaking is done in IIS. Be sure to enable anonymous authentication so traffic will not be blocked.
While as almost everyone stated already - it's impossible using just DNS. As a workaround I would suggest trying NGINX (http://nginx.org/en/docs/http/request_processing.html). TL;DR - In NGINX you can create multiple virtual servers that can redirect your request based on the server name. Ex. http://first.my-server.com redirect to place A and http://second.my-server.com redirect to place B, while both share a single physical server.
You can use htaccess rewrite mod, rewrite to the subfolder if the user is requesting one specific domain not the other.
Of course it is possible to redirect, with the following trick: Create a new standard primary zone Name it same as the fictive URL that you want to redirect to Ensure that this fictive name is different than any AD DNS name Create A record with following entries: blank.......................A............................ip-addr-2 www.........................A............................ip-addr-2 What we have here is redirection, essentially. A valid URL will resolve based on the existing DNS primary DNS zone. A fictive URL will be redirected to ip-addr-2. What is important is that the name of this entry is blank, so it will fall down to the next entry in the record and redirect to ip-addr-2
Everyone has already stated this, and I just want to give you another option to a service that can help you. www.301redirect.it is a free service that can redirect your domain (with wildcard) to any destination url. I want to add a disclosure as well: I'm the developer behind this service and there is a other options out there.