我试图设置一些Nginx标题,运行在B4上。
这是我在我的app.yaml文件中放置的代码:
runtime_config:
nginx_conf_http_include: nginx-http.conf 这是nginx-http.conf文件的内容:
# Security headers
server_tokens off;
add_header X-Frame-Options SAMEORIGIN always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header Content-Security-Policy "default-src 'self';" always;
add_header Referrer-Policy no-referrer;
add_header Feature-Policy "geolocation none;midi none;notifications none;push none;sync-xhr none;microphone none;camera none;magnetometer none;gyroscope none;speaker self;vibrate none;fullscreen self;payment none;";这些标头在部署后都不可用。
救救伙计们!
发布于 2020-05-29 18:44:00
nginx_conf_http_include配置项仅适用于Flex环境和PHP,这就是它不能工作的原因。最好的方法是使用处理程序元素,更具体地说是http_headers来设置标头,例如:
handlers:
- url: /images
static_dir: static/images
http_headers:
X-Foo-Header: foo
X-Bar-Header: bar value
# ...https://stackoverflow.com/questions/62069164
复制相似问题