How to route traffic to different url if load balancer receive 404 from backend

I am using https://github.com/domZippilli/gcs-proxy-cloud-run to redirect the traffic from internal load balancer to cloud storage bucket. Mz bucket has different sub folder which acts as different website. Bz using the full url path I am able to access the web static pages from the proxy. Now I have to configure the different error pages based on the different sub folder. So if we get a 404 from one sub folder(Through the proxy) then the load balancer should redirect the url to a different web page for help. Is it achievable with ilb configuration or it needs be configured in proxy code?

2 2 601
2 REPLIES 2

Hello @subhajit2022,

Hope you are doing well.

I can help with some understanding point.

Let's consider an example using the Nginx web server as a load balancer. In this scenario, Nginx is configured to redirect traffic to a different URL when it receives a 404 error from the backend.

1.Install Nginx
2.Configure Nginx
3.Add a Location Block for Error Handling
4.Test and Reload Nginx

Now, when the backend server returns a 404 error, Nginx will redirect the traffic to the specified URL. Adjust the configuration according to your specific requirements and the documentation of your load balancer. If you are using a different load balancer, refer to its documentation for guidance on handling error responses and redirecting traffic.

Thank You. 

Thanks for your reply. Hope you are doing well. Currently I am using gcp internal load balancer . The ILB forward the traffic to my cloud run gcs proxy which fetches the static content from gcs bucket . It seems gcp ilb does not have any mechanism to configure the redirection of traffic based on response header (http status)from backend service.