http -> https redirect in Google Kubernetes Engine

后端 未结 5 665
南方客
南方客 2021-02-07 23:09

I\'m looking to redirect all traffic from

http://example.com -> https://example.com like how nearly all websites do.

I\'ve looked at this link with no success:

5条回答
  •  温柔的废话
    2021-02-08 00:02

    GKE uses GCE L7. The rules that you referenced in the example are not supported and the HTTP to HTTPS redirect should be controlled at the application level.

    L7 inserts the x-forwarded-proto header that you can use to understand if the frontend traffic came using HTTP or HTTPS. Take a look here: Redirecting HTTP to HTTPS

    There is also an example in that link for Nginx (copied for convenience):

    # Replace '_' with your hostname.
    server_name _;
    if ($http_x_forwarded_proto = "http") {
        return 301 https://$host$request_uri;
    }
    

提交回复
热议问题