Simply put, you cannot , at least for now.
The cloud load HTTP balancer you found is in alpha, you need to ask for a whitelist to try. But this will not solve your problem. Since there is currently no way to control the load balancing redirection manully based on backend responses. I do not think it will be possible. This is not the goal of load balancing in GCP.
You can also configure a custom index page and a custom error page that will be serviced if the requested object does not exist.
The above statement means that you can create a custom 404 page for unreasonable objects in a bucket. This does not mean that you redirect traffic if your back services do not work (502). There is a big difference between: I cannot find the page, and nothing works because I do not have a server.
You can only redirect traffic from outside to inside your network. You cannot do the opposite. You cannot request load balancing overload based on response.
Instead of trying to make the 502 error page look beautiful, ask yourself why you have it and try to fix it.
Hakro source share