How to set up Google Cloud Storage Load Balancer to point different domains to specific folders on the same bucket? - google-cloud-storage

I can't find a way to set up Google's Cloud Storage load balancer's host path and rules to point different domains to their corresponding folders in a single bucket.
I have two domains: foo.com and bar.com and I have a bucket with two folders in it: foo/ and bar/. I want foo.com to serve files from the foo/ folder and bar.com to serve files from the bar/ folder.
I only see options to point specific domain paths to different buckets (e.g. foo.com/bar/ pointing to another bucket) but not different hosts/domains to different paths in bucket. How can I set up the rules to achieve this?

You need to use the advance feature of HTTPS load balancer and especially the URL prefix rewrite.
For that, you need to configure your host and path rules in advanced mode. Then, for the default access (without specific domains), you can redirect (URL REWRITE) to the /default folder of the backend.
Add host and path, and for foo.com, redirect to the folder /foo by rewriting the prefix
Do the same for bar.
Wait 5 minutes (let the Load Balancer to advertise the POP), and enjoy :)

Related

Google cloud platform - Set up a 301 redirect from www

When I was on AWS, setting up a 301 redirect for my website from www.example.com --> example.com involved simply creating a S3 bucket as a static website and set it up to redirect all traffic to example.com.
I don't see this option on Google cloud storage and I can't think of any way to do this with the HTTP load balancer.
Is the only way doing it involves patching my backend to notice addresses that start with www and strip the www and redirect ?
Google has a way of using buckets as backends for the http load balancer.
It is still in alpha but you can read about it and ask them to try it here. Use it with a html file to redirect like suggested here and my guess it should work.
Alternatively, I use Cloudflares free service, which allows for 3 free redirects. Saving you the trouble of configuring redirects in your backend. This can be done with some other CDN services as well I don't know which.

IIS Redirects - Redirecting domain without website binding

I have a bunch of domains (50+), e.g. example1.org example2.org, example3.org that I would like to redirect (301) to a single domain, examplethebest.org. Nothing is hosted on any of these domains other than examplethebest.
I've set up all the example domains in the registrar's DNS to point to the IP of my web server.
I was wondering if redirecting these is something I could achieve via rewrites in the applicationHost.config file. Or do I need to add bindings for example1 - example3.org in examplethebest's website bindings?
Just wanted to add that I understand how to do the rewrites via the web.config in examplethebest if I add bindings for the domains I want to redirect, but would rather not have loads of domain bindings - e.g. what is best practice here? Thanks!
Okay so the issue I had on this particular web server was that the default website (listening to all requests on port 80) was stopped - the other websites all had specific bindings.
At least two possible solutions for this one:
Starting the default website and adding {http_host} rewrites in there
Creating another website, make it listen to all requests on port 80 with just a web.config and putting the {http_host} rewrites in there.
We went with option 2.

Pointing 1and1 domain to an S3 bucket

I've registered my domain about a month ago (It's a .com, so I need to wait 60 days before being allowed to transfer the domain, which I will do as I'm fed up with 1and1's service)
I created an Amazon S3 bucket with my domain name: example.com and www.example.com.
All my Amazon S3 settings are in order, I've enabled website hosting, I have an index document...
In 1and1, I've set my redirect destination for example.com to my S3 bucket endpoint.
When I hit save: "Operation Failed, The redirect URL is invalid."
What am I doing wrong?
You do not have to wait 60 days.
There are two different services that are commonly confused because providers often market then together: domain registrar services and domain hosting.
You can change your hosting provider at any time, by changing the configuration options with the current registrar. This change typically takes effect almost immediately, though conventional wisdom is that it may require up to 48 hours to take effect globally.
Create a new "hosted zone" in Route 53 for your domain. Take note of the four "awsdns" name servers that Route 53 assigns.
Log in to your registrar's admin portal and find the option the change your authoritative name server configuration. Replace the registrar's default name servers with the four provided by Route 53.
You will then use the Route 53 console to create your DNS records, including the appropriate "Alias" records pointing your domain to the S3 web site endpoint.
After the 60 days, you can change the registrar to Route 53, or any other registrar you like, continuing to use the authoritative name servers assigned to your domain by Route 53.
Route 53 is the simplest option for DNS hosting when you are using S3 for static website hosting (or CloudFront or Elastic Load Balancer) simply because of the tight integration provided by Alias records, which offer capabilities that CNAMEs can't and other DNS hosting providers can't, because they don't have direct access to the operational internals of AWS.
It sounds like you configured your domain name to use a Redirect instead of a CNAME record. Create a CNAME record to your AWS domain.
Here are some instructions:
http://help.1and1.com/domains-c36931/manage-domains-c79822/dns-c37586/enter-a-cname-record-for-your-domain-a643600.html
Sometimes people don't want to create CNAMEs for their root domain and prefer to redirect from example.com to www.example.com

Subdomain redirect to subdirectory

I have a domain in which I want the subdirectory to be shown as a subdomain in the url.
I do not want it to be a subdomain because it'll cause problems with the integration of two cms's that I have.
I would like
forum.domain.com -> domain.com/forum
to redirect to there but I would also like it to keep saying forum.domain.com in the url and not change to /forum.
I do have access to the DNS zones but I am completely lost on how to do this. So far my forum.domain.com is a website by itself in which I do not want it to be.
*Server Htaccess is running helicon ape.
This cannot be done purely through DNS. It's not hard, but it does involve your web server's configuration.
In DNS, create a CNAME (an alias) for forum.domain.com to point to your server, probably domain.com.
In your webserver's configuration, configure a new virtual host with that path as its document home. The way you do this will depend on whether you use Apache, Nginx, etc.

redirect root domain name to amazon s3

My domain is rather long. I need to use it without www.
All the info I find on the net is about cnames.
How do I redirect the whole domain to an amazon s3 bucket, not only a subdomain?
Amazon recently announced support for root domain hosting via S3. The instructions for setting this up can be found here. Note that you will have to setup two buckets to accomplish this, and that you will have to use Route 53 for your DNS hosting.
Try wwwizer
What you need to do is to create a cname www pointing to your s3 bucket url (bucket name will need to match) and then create an A record to the ip given by wwwizer.
Another way is to use a url redirecting service or use a free web host (like godaddy's ad supported hosting) and on the index file issue a redirect to www.yourdomain.com.
There might be other solutions that rely on finding out the ips of the amazon s3 front end servers but they are error prone.