【问题标题】:GKE GCE Ingress FrontendConfig redirect non-www to wwwGKE GCE Ingress FrontendConfig 将非 www 重定向到 www
【发布时间】:2022-06-11 21:35:44
【问题描述】:

我想将所有非 www 流量重定向到 www 流量。例如。 mydomain.comwww.mydomain.com

GKE Ingress (GCE) 使用Frontendconfig。有没有办法配置 FrontendConfig 将非 www 流量重定向到 www 流量。

按照本指南 (https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features) 创建 FrontendConfig。在该指南中没有提及此类功能。

【问题讨论】:

  • 能否分享您的 Ingress 配置/yaml 文件。

标签: google-cloud-platform google-kubernetes-engine


【解决方案1】:

我也在寻找相同的功能。当我为我的域使用谷歌管理的 ssl 证书时,唯一的选择是使用gce ingress。我现在通过以下工作设法做到了这一点。

我有一个 Nginx Sidecar 容器,位于我的 Web 应用程序容器之上,并执行此重定向。示例 Nginx 配置如下。

server {
    server_name example.com;
    return 301 https://www.example.com$request_uri;
}

捕获所有配置如下。

server {

    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;

    location / {
        proxy_pass http://127.0.0.1:3000; # my web app
    }

}

【讨论】:

    猜你喜欢
    • 2021-06-24
    • 2018-06-06
    • 1970-01-01
    • 2019-03-09
    • 2021-08-03
    • 2011-11-05
    • 2011-12-01
    • 2013-12-20
    相关资源
    最近更新 更多