我的app.yaml中有以下处理程序部分
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)服务的另一个子域具有以下内容:
handlers:
- url: /
static_dir: files
secure: always
http_headers:
Access-Control-Allow-Origin: '*'
Strict-Transport-Security: 'max-age=63072000; preload'我能够毫无问题地将static.yaml部署到appengine:
$ 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然而,当我尝试更新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个处理程序。除了更新其中的每一个来添加STS头之外,有没有在app.yaml级别本身这样做的替代方案呢?
检查app.yaml reference on GAE,没有提到http_header指令在script类型映射中的限制。
发布于 2017-08-26 04:53:11
您可以使用app.yaml来控制静态文件处理程序而不是动态处理程序的HTTP headers。你需要在你的应用程序代码中设置头部。
发布于 2017-05-25 02:22:54
作为文档:https://cloud.google.com/appengine/docs/flexible/nodejs/using-custom-domains-and-ssl
您不能使用Strict-Transport-Security标头,除非您的域被列入白名单。要将您的域名放入白名单,请联系...
更新
2018年起,自定义域名不再需要加入白名单。换句话说,HSTS标头不再被剥离。
发布于 2016-12-08 03:14:58
我今天在app.yaml中查看了http头文件,发现了这个。这似乎与您的问题有关。
此外,从*.appspot.com以外的任何域提供的响应中删除报头Strict-Transport-
。
https://cloud.google.com/appengine/docs/python/how-requests-are-handled#Python_Responses
https://stackoverflow.com/questions/39544193
复制相似问题