问题原文
原帖链接 · Ryan Leckey · CC BY-SA 3.0
I have HTTP/HTTPS Load Balancing set up on Google Compute Engine with 2 Global Forwarding Rules (HTTP and HTTPS). Each rule points to a back-end service with a protocol of HTTP.
I want all requests to http://* to go to https://*.
As the load balancer talks to the back-end services over HTTP I don't think I can get nginx on the back-end service to send back a 301.
I've tried a dozen small tweaks on google compute and they all end up with google compute returning a 502.
I'm sure somebody else has set this up before. Any tips or pointers in the right direction are much appreciated.
已采纳解答
原帖链接 · Lennert Kuijpers · CC BY-SA 3.0
We have a similar setup using the HTTP / HTTPS load balancer and we managed to force HTTPS. Its not possible directly from the load balancer but you can set it up from your backend service. The Google Cloud load balancer will set the X-Forwarded-Proto http header with either the value http or https. You check this header in your backend service (in our case Varnish but this could also be done in Nginx) and if the value is http then you send back a 301.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
