Load Balancing – How to use GCP Load Balancer to redirect all HTTP requests to HTTPS

I have set the standard GCP load balancer to point to my instance group. It communicates on the same port on the instance. I want to redirect http to https. I usually Do this in nginx or apache on the instance, but since its https already comes from the load balancer, it does not work.

Is there a way to rewrite the URL similar to whether I use nginx and apache Load balancing in GCP’s load balancer? Or should I forward http and https to the instance and let the instance handle the rewrite as usual. I thank the newbies in GCP in advance.

< div class="answer"> You can set it up like Nginx. When you see traffic on a port other than https, you redirect it to HTTP.

For this, you You can use the X-Forwarded-Proto header, which contains the protocol used by the traffic. On your server, you just need to look for the traffic with the http header and upgrade the request to HTTPS.

The usual method is to use 301 redirects, but this is not a good practice. HTTP 426 upgrade request headers should be used.

Read more: Is HTTP status code 426 Upgrade Required only meant signal an upgrade to a secure channel is required?

RFC doc: http://tools.ietf.org/html/rfc2616#section-14.42

Me I have set the standard GCP load balancer to point to my instance group. It communicates on the same port on the instance. I want to redirect http to https. I usually do this in nginx or apache on the instance, but Since its https already comes from the load balancer, it cannot work properly.

Is there a way to rewrite the URL similar to whether I use nginx and apache to load balance in the GCP load balancer? Or should I forward http and https to the instance and let the instance handle the rewrite as usual. I thank the newbies in GCP in advance.

You can be like Nginx Set it up. When you see traffic on a port other than https, you redirect it to HTTP.

For this, you can use the X-Forwarded-Proto header, which contains The protocol used by the traffic. On your server, you only need to find the traffic with http headers and upgrade the request to HTTPS.

The most common method is to use 301 redirects, but this is not A good practice. HTTP 426 upgrade request headers should be used.

Read more: Is HTTP status code 426 Upgrade Required only meant signal an upgrade to a secure channel is required?

< p>RFC doc: http://tools.ietf.org/html/rfc2616#section-14.42

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2446 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.