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


*Franken (Honmachi)

Hello!
This is Hide, the Ramen King from Beyond Co., Ltd.'s Osaka office.
This is my 8th post.

Last time, I wrote about how to install a free SSL certificate with Google Cloud Load Balancing (GCLB) on GCP!
I wrote an interesting blog post about installing a free SSL certificate, which is something surprisingly few people know about, so if you're interested, please 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 to redirect to
. ● Action: Redirect the client to a different host/path.
● Host Redirect: Specify the redirect destination.
● Path Redirect: Please select an appropriate option.
● Redirect Response Code: 301
● HTTPS Redirect: Please select an appropriate option.
● Query Deletion: Please select an appropriate option.

*Reference:Official documentation on URL redirection settings

 

⑥ Operation check

*Please wait until the LB update is complete before proceeding.
* 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 helpful,please give it a "Like"!
2
Loading...
2 votes, average: 1.00 / 12
2,590
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Hide@Infrastructure Engineer

thanks to an incredibly interesting interview.
I joined the company mid-career in the System Solutions Department in Osaka,
My work involves building and operating servers and cloud services!
I also hold LPIC1, AWS SAA, and OCI Architect Associate certifications.

Actually, I love ramen and
have already investigated over 100 ramen shops in Osaka (。-∀-) I'm striving to become the Ramen King of Nihi Beyond
ビヨンドのラーメン王を目指し奮闘中!!

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