1

Is there a way to create forwarding rules that redirect to a different host?

For example, I want to set up a load balancer with a rule that if the host = xyz.com then forward to host = abc.com Is this type of setup possible?

fuzzi
  • 1,967
  • 9
  • 46
  • 90
  • 1
    Hello @fuzzi, do you mean redirect from one domain to another different domain? as example: redirect from facebook.com to instagram.com – Alejandro F. Nov 04 '21 at 16:12
  • Could you specified what kid of load balancer are you trying to deploy? – Alejandro F. Nov 04 '21 at 16:24
  • @ArdenSmith yes, I'm referring to a redirect such as facebook.com to instagram.com, where instagram.com is not a backend service, but a public domain. – fuzzi Nov 05 '21 at 18:39

1 Answers1

2

Let me help you with this.

Forwarding rules

A forwarding rule and its corresponding IP address represent the frontend configuration of a Google Cloud load balancer.

Note: Forwarding rules are also used for protocol forwarding, Classic VPN gateways, and Traffic Director to provide forwarding information in the control plane.

Each forwarding rule references an IP address and one or more ports on which the load balancer accepts traffic. Some Google Cloud load balancers limit you to a predefined set of ports, and others let you specify arbitrary ports.

The forwarding rule also specifies an IP protocol. For Google Cloud load balancers, the IP protocol is always either TCP or UDP.

Depending on the load balancer type, the following is true:

  • A forwarding rule specifies a backend service, target proxy, or target pool.

  • A forwarding rule and its IP address are internal or external.

Also, depending on the load balancer and its tier, a forwarding rule is either global or regional.

As is mentioned the Forwarding rule specified a backed service which can help you to reach your deployment.

Additionally I want share with you the following information abiut the URL Mapping, which can help you too.

URL maps

Google Cloud HTTP(S) load balancers and Traffic Director use a Google Cloud configuration resource called a URL map to route requests to backend services or backend buckets.

For example, with an external HTTP(S) load balancer, you can use a single URL map to route requests to different destinations based on the rules configured in the URL map:

Requests for https://example.com/video go to one backend service.

Requests for https://example.com/audio go to a different backend service.

Requests for https://example.com/images go to a Cloud Storage backend bucket.

Requests for any other host and path combination go to a default backend service.

URL maps are used with the following Google Cloud products:

External HTTP(S) Load Balancing (global and regional)

Internal HTTP(S) Load Balancing

Traffic Director

There are two types of URL map resources available: global and regional. The type of resource that you use depends on the product's load balancing scheme.

There is another solution named "HTTP-to-HTTPS redirect" to redirect all requests from port 80 (HTTP) to port 443 (HTTPS).

HTTPS uses TLS (SSL) to encrypt HTTP requests and responses, making it safer and more secure. A website that uses HTTPS has https:// in the beginning of its URL instead of http://.

But I am not sure if the HTTP-to-HTTPS fits with your description.

I hope this information help you to chose the best option for your deployment.

Alejandro F.
  • 410
  • 3
  • 10
  • Thank you for your answer! I'm not sure if any of these solution meet the needs of redirecting to a different domain? - As I understand, backend service, target proxy, or target pool all must refer to google services. – fuzzi Nov 05 '21 at 18:42
  • 1
    That is correct. – Alejandro F. Nov 08 '21 at 23:02