Google HTTP负载平衡强制执行HTTPS

Upi*_*pio 5 load-balancing google-cloud-platform gcloud

我在Goole Cloud上有一个HTTP和HTTPS负载均衡器.是否可以将其设置为强制(重定向)所有HTTPS连接?

Mat*_* S. 4

截至 2015 年 6 月,不在负载均衡器中。

作为替代方案,您可以将 Web 服务器配置为对重定向到 HTTPS 版本的所有 HTTP 请求返回 301。

对于 Apache(来自https://wiki.apache.org/httpd/RedirectSSL):

NameVirtualHost *:80
<VirtualHost *:80>
   ServerName www.example.com
   Redirect permanent / https://www.example.com/
</VirtualHost>

<VirtualHost _default_:443>
   ServerName www.example.com
   DocumentRoot /my/document/root
   SSLEngine On
   # .. etc .
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

对于 nginx(来自https://serverfault.com/questions/67316/in-nginx-how-can-i-rewrite-all-http-requests-to-https-while-maintaining-sub-dom):

server {
    listen [::]:80;
    return 301 https://$host$request_uri; 
}
Run Code Online (Sandbox Code Playgroud)