How to host a site a website without WWW in Google Cloud - google-cloud-platform

I recently hosted a site in google cloud. For that, I've created a bucket named www.mydomain.com And I've followed all the steps and the website is working fine if I put URL like www.mydomain.com but not when I put mydomain.com without www. What is the best way to achieve this? How can I make the URL mydomain.com work?
Thanks in advance

This setting has to be made on your domain registration service, not on Google Storage side.
In your DNS settings, you will have to redirect domain.com to www.domain.com. Note that being able to do this will depend on your provider.
If that is not an option you could use a Compute Engine instance free tier or App Engine to redirect the requests from yourdomain.com to www.yourdomain.com
Also, CDN is used for caching content so I don't think you have your CNAME there, maybe you are referring to Cloud DNS?
If that is the case, you will not be able to do the redirect just using Cloud DNS so you will have to use one of the other options

Related

Google Domains to AWS Route53 HTTPS

I have a domain hosted through Google. I'm using Google Workspace for a lot of my day-to-day operations (e.g. Drive, Gmail, etc). I'm using AWS as my infrastructure and business logic for my application. I'm having trouble making my site support TLS. If you visit it now, you get this on chrome and I can't seem to make HTTPS requests work.
I have my domain pointing to AWS via Custom Name Server.
My route 53 has the NS type records listed under the hosted zone
I've tried to request a Certificate from AWS to make it work.
My problem is I don't know how to tell Google about it. How do you let Google know about the certificate so I can make my site HTTPS?
I believe approaching Google is not going to solve your issue as in the above case Google is only responsible to host your domain . So DNS setup is only responsible to route requests to your site and not making your site more secured.
I also found that you are exposing your site as http rather than https and thats why your site is unsecured.
Is your site is running on a web server or is it hosted on S3 as static web site ?
Note: you cant enable https on S3 static website.
The workaround to above problem is below :
Route53 has A record to pointing to ALB (configured with ACM) distributing traffic to Ec2 instances running your web application.
If anyone is still looking. I wanted to keep it cheap with a simple S3 static website. If you want to maintain the S3 part, make a CloudFront distribution (if you haven't already.
Inside the CloudFront under the main settings, use a Certificate you made from Certificate Manager.
Then head over to Route53 (even if the domain is hosted via Google) and route the "A" name record to the CloudFront. NOTE: make sure the "Alternate Domain" name is filled in or else it won't see it.
Let it update for about a minute or two and it will show https

Google Domain and AWS S3 Static Page

Good Afternoon,
I have followed a few tutorials on this topic and I have researched to see what I may be missing, but so far I haven't come up with anything. I'm sure it's a simple fix I just need a bit of help.
So I have the domain brandonkjones.dev that I purchased through Google Domains and I am trying to forward it to a static page hosted on S3. I created the hosted zone in Route 52 with the name brandonkjones.dev.
and I changed the Google Domain name servers to match those generated by the hosted zone.
I also added the additional records to forward the subdomain www to the root domain.
and Finally, I added the CNAME entry to the custom resource records on Google.
I'm sure this tutorial left off a step and I'm missing something because the original tutorial didn't even mention adding the CNAM resource within Google. Any help is greatly appreciated.
I had this same issue, tried with multiple browsers and triple checked that I'd done all the Route 53 and Google Domains steps correctly to no avail. Then I opened my terminal and tried:
curl http://my-domain.dev
and it returned my index.html that I uploaded to my S3 bucket, meaning I'd done everything correctly, but my browser wouldn't let me access the website over HTTP. In my devtools network tab, I could see that even if I explicitly typed in http://my-domain.dev it would do a 307 internal redirect to https://my-domain.dev. This is a security feature that browsers have to keep users from navigating to insecure sites over http.
Since the tutorials I followed for setting up S3 static hosting with a custom domain registered on Google Domains did not setup any SSL certificates for enabling HTTPS, the only way I could access my website was over HTTP. One way to fix this issue is to turn off HSTS as outlined here. Or, you could use something like AWS CloudFront to serve your S3 site over https, which you'll probably want to do if you want other people to access your site without this issue.

How to redirect Domain on Amazon AWS to an external link

We have all of our domains and setup on Amazon AWS. We have created a not so complex kinda static website which is hosted on a Linux machine at a hosting company. Now we have to redirect the domain e.g. example.com and www.example.com to that url which is like temp.example.hostingcompany.com.
How can I redirect example.com and www.example.com to that url so that the user sees our url and the contents on that url are displayed.
Note: I want to make it work for both http and https. We are using Amazon https certificates.
I know we can host static websites using S3 Buckets on Amazon but its already been hosted somewhere else and I can't change that decision now.
Thanks.
If you want to migrate the website to the new domain, than its simply setup the codebase on new server and make appropriate domain changes it will work.
Secondly, If you want to just show the website on the new domain, but internally its still being available on old domain, than you can use any reverse proxy server like nginx, and use the old domain as the backend and your new domain as its front end.

Amazon S3 Static Hosting Custom Domain

I'm learning some web development and am using Amazon S3 as a web host with a custom domain from Google domains. I used the guides from the Amazon AWS page and was able to set up the web page but I have a problem with getting the custom domain to work.
For example, Amazon S3 has the endpoint URL to www.example.com.s3-website-us-east-1.amazonaws.com and I want my domain example.com to show up. When I load the page for www.example.com, it loads the page however it still shows the example.s3-website-us-east-1.amazonaws.com when I want it to show the simple example.com instead.
From what I can tell, I need a CNAME, I've set it up as www.example.com -> www.example.com.s3-website-us-east-1.amazonaws.com with permanent redirect (301) and forward path.
Please help!
If anyone was wondering how I got it to work, I ended up using Cloudflare with its free DNS options. I added the DNS servers to google domains and then added two CNAMES:
# -> example.com -> example.com.s3-website-us-east-1.amazonaws.com (for the root)
CNAME -> www -> www.example.com.s3-website-us-east-1.amazonaws.com (for the www redirect)
On the Google side, configure the CNAME record (www) to point to s3.amazonaws.com. (yes, the dot included) ... like this:
... and wait a few minutes.
Make sure your S3 bucket is named: www.yourdomain.com

How do you use Amazon Route 53 to redirect a subdomain to a specific page?

I would like to redirect my subdomain "subdomain.example.com" to a specific page on my site "example.com/specific-page" using Amazon Route 53. Is this possible?
I saw this answer and tried it (Set up DNS based URL forwarding in Amazon Route53) but that appears to only allow you to redirect to root domains, not specific pages on that domain.
Is this possible with Route 53?
Set up Route53 to point to the subdomain. The rest should be handled by your webserver.
For Apache, you can use .htaccess.
For NGINX, I'd set up the server and location blocks accordingly.
I don't believe that this is possible.
You could set up a DNS wildcard, so that *.example.com was mapped to a specific server, and then that server could use something like mod_rewrite to redirect from somename.example.com to example.com/somename.
This is actually fairly simple.
Follow the instructions outlined in the original example, except do not follow step #3.
Instead of following step #3 do this:
In the S3 Properties for subdomain.example.com select Static Website Hosting.
Select the radio button for Redirect all requests to another host name.
In the textbox, enter example.com/specific-page.
Click Save.
Proceed with the rest of the steps as outlined in the original example.
Your bucket should look like this:
You could solve this problem by creating an S3 bucket, enabling the bucket for static web hosting. On the static web hosting tab in the bucket, you can configure a redirect rule, set that redirect rule to https and set the redirect host to the desired address e.g.example.com/blabla
Then go over to Route53, configure a A record for the hosted zone, enable Alias, and point the A record to the S3 bucket endpoint.