[Part 1] How to set up URL redirection with GCP's global external HTTP(S) load balancer (traditional type)


*Franken (Honmachi)

Hello!
I'm Hide, the Ramen King from Beyond Inc.'s Osaka office.
This is my eighth post.

Last time, I wrote about how to set up a free SSL certificate with GCP's Google Cloud Load Balancing (GCLB).
I also wrote an interesting blog post about setting up a free SSL certificate, which is surprisingly unknown, so if you're interested, be sure to check it out!

How to set up a free SSL certificate with a GCP load balancer (GCLB)

How to set up a free SSL certificate with a GCP load balancer (GCLB)

Google Cloud Load Balancing (GCLB) URL Redirect

URL redirection means that when you access a certain URL, you are automatically redirected to another URL, such as when you access example.com, you are automatically redirected to example2.com. Most of the time, this can be configured in Apache or Nginx on the web server

In this case, access will go directly to the web server, which may increase the load on the server, but if there is a load balancer (LB) in front of the server, URL redirection settings can be performed on the LB alone, reducing the load on Apache, Nginx, and other web servers

You can also set up URL redirects with Google Cloud Load Balancing (GCLB), but the method for setting up URL redirects differs between the "Global HTTP(S) Load Balancer" and the "Global External HTTP(S) Load Balancer (Legacy)." The legacy type is easier to set up than the Global HTTP(S) Load Balancer

It is very difficult to set up just by looking at the documentation, but if you look at this blog, you will be able to easily set up URL redirection, so let's set it up together!

Setup Procedure

*This assumes that a load balancer (LB) has been created

① Click Load Balancing > LB Name > Edit

 

② Select Advanced Host and Path Rules and click [Add Host and Path Rule]

 

③ Specify the source domain in the new host and path rule

 

④Click [Add path rule]

 

⑤ Set up redirection

● Path: Specify the path when redirected
● Action: Redirect the client to another host/path
● Redirect Host: Specify the redirect destination
● Redirect Path: Choose the appropriate one
● Redirect Response Code 301
● HTTPS Redirect: Choose the appropriate one
● Delete Query: Choose the appropriate one

*Reference: Official URL redirect settings document

 

⑥ Operation check

*Please wait until the LB update is complete.
*Please check if you are redirected.

 

 

summary

What did you think?

Traditional global HTTP(S) load balancers make it easy to set up redirects, so I think I was able to set up redirects with GCLB quickly

However, if you can properly set up the redirection on the load balancer, you can redirect without putting a load on the server, so it is recommended!

If you are setting up a redirect with GCP LB, please refer to this article!

If you found this article useful, please click [Like]!
2
Loading...
2 votes, average: 1.00 / 12
2,524
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Hide@Infrastructure Engineer

It all started with a really interesting interview.
I joined the System Solutions Department in Osaka mid-career and
am currently involved in the construction and operation of servers and clouds!
I hold LPIC1, AWS SAA, and OCI Architect Associate certifications.

In fact, I love ramen and
have investigated over 100 ramen shops in Osaka (。-∀-) I am striving to become the ramen king of Nibi Beyond

I'm also on Twitter, so please follow me (´∇`)
Click on the Twitter mark in the right corner!!