【问题标题】:How to Force SSL on Google App Engine Flexible Environment如何在 Google App Engine 柔性环境中强制使用 SSL
【发布时间】:2018-08-21 02:40:58
【问题描述】:

是否有文档显示如何在 Google App Engine - 灵活的 PHP 上强制使用 HTTPS?

我尝试将 secure 放在 app.yaml 上,但没有运气。

我也尝试在 nginx-app.conf 中放置这个,但没有运气。

我也试过了

set $test "";

if ($http_x_forwarded_proto = 'http') {
    set $test "http";
}

if ($test = 'http-non-cron') {
    return 301 https://$host$request_uri;
}

我尝试过的其他选项

<?php     
     header("Strict-Transport-Security: max-age=31536000; includeSubDomains; preload");  
     exit();  
?>

但没有运气。

【问题讨论】:

标签: php google-app-engine


【解决方案1】:

使用以下代码(从比较中删除-non-cron):

set $test "";

if ($http_x_forwarded_proto = 'http') {
    set $test "http";
}

if ($test = 'http') {
    return 301 https://$host$request_uri;
}

如果您有 cron 处理程序,则必须允许这些处理程序的 http 访问配置如下:

set $test "";

if ($http_x_forwarded_proto = 'http') {
    set $test "http";
}
if ($request_uri != '/cron/') { # everything under /cron/
    set $test "${test}-non-cron";
}
if ($test = 'http-non-cron') {
    return 301 https://$host$request_uri;
}

【讨论】:

    猜你喜欢
    • 2017-06-16
    • 1970-01-01
    • 2019-04-24
    • 1970-01-01
    • 2018-04-12
    • 2021-01-29
    • 2018-11-28
    • 1970-01-01
    • 2021-05-03
    相关资源
    最近更新 更多