2016-09-17 22 views
1

私は私のapp.yamlで、次のハンドラセクションがあります。追加HSTSヘッダ(Google App Engineの)

handlers: 
    - url: /(robots\.txt|sitemap\.xml) 
    static_files: \1 
    upload: (robots\.txt|sitemap\.xml) 
    secure: always 
    http_headers: 
     Strict-Transport-Security: 'max-age=63072000; includeSubDomains; preload' 
    - url: /.* 
    script: main.app 
    secure: always 
    http_headers: 
     Strict-Transport-Security: 'max-age=63072000; includeSubDomains; preload' 

をし、別のサブモジュール(static.yaml)によって提供される別のサブドメインは、以下があります。

$ appcfg.py update static.yaml 
12:48 PM Host: appengine.google.com 
12:48 PM Application: XXXXXX; module: static; version: 1 
12:48 PM 
Starting update of app: XXXXXXXX, module: static, version: 1 
12:48 PM Getting current resource limits. 
12:48 PM Scanning files on local disk. 
[...] 
[...] 
12:49 PM Checking if updated app version is serving. 
12:49 PM Completed update of app: XXXXXX, module: static, version: 1 
012:
handlers: 
    - url:/
    static_dir: files 
    secure: always 
    http_headers: 
     Access-Control-Allow-Origin: '*' 
     Strict-Transport-Security: 'max-age=63072000; preload' 

は私が有力候補に何の問題もなくstatic.yamlを展開することができました私はapp.yaml設定を更新しようとすると、

が、一方で、私が取得:

$ appcfg.py update app.yaml 
12:48 PM Host: appengine.google.com 
Usage: appcfg.py [options] update <directory> | [file, ...] 

appcfg.py: error: Error parsing .\app.yaml: Unexpected attribute "http_headers" for mapping type script. 
    in ".\app.yaml", line 31, column 1. 

私はそれは私が私のPythonスクリプト自体にHSTS構成を処理する必要があるだろう意味することを理解します。しかし、main.appインターフェイスに〜10ハンドラがあります。 app.yamlレベルでそれを行うにはいくつかの代替はありますか?

app.yaml reference on GAEを確認すると、scriptタイプマッピングのhttp_headerディレクティブの制限はありません。

答えて

2

https://cloud.google.com/appengine/docs/flexible/nodejs/using-custom-domains-and-ssl

あなたのドメインをホワイトリストに登録されていない限り、あなたは厳格な-交通-Securityヘッダーを使用することはできません。

UPDATE 2018のよう

...ホワイトリスト、連絡先にドメインを配置するには、カスタムドメインをホワイトリストに登録する必要はありません。言い換えれば、HSTSヘッダーはもはや取り除かれません。

+0

これは古くなったと思います。そのドキュメントにはホワイトリストが記載されなくなりました。 –

+1

リンク先はまだ変更されていません。https://cloud.google.com/appengine/docs/flexible/nodejs/securing-custom-domains-with-ssl – dmitrych

3

app.yamlを使用して、動的ハンドラではなく静的ファイルハンドラに対してHTTP headersを制御できます。あなたは、アプリケーションコード内のヘッダーを設定する必要があります。