在nGinx Staticfile构建包中添加X-Frame-Options

时间:2019-06-25 21:39:10

标签: nginx cloudfoundry

我需要在nginx CF中添加以下X-Frame选项。

php artisan migrate:fresh

我正在使用Cloud Foundry Staticfile构建包。

如果我直接编辑nginx.conf,则每次部署应用程序时都会将其删除。因此建议通过Staticfile buildpack添加。

但是我不知道x帧选项的确切值。

参考:https://docs.cloudfoundry.org/buildpacks/staticfile/index.html

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

正确的,您不想直接编辑配置文件。下次重新启动,重新启动,重新创建,崩溃,甚至由于维护而平台再次移动应用程序时,更改将消失。

如果您遵循instructions for adding custom Nginx configuration,则可以将配置放入代码段中,由Staticfile buildpack生成的Nginx配置将自动读取您的配置代码段。

希望有帮助!

答案 1 :(得分:0)

Nginx.conf 文件启用 X-Frame-Options

location ~* \.(?:html)$ {
  try_files $uri =404;
  add_header Cache-Control  'no-cache, no-store, must-revalidate, max-age=0';
  add_header X-Frame-Options 'SAMEORIGIN';
  add_header X-Frame-Options 'DENY';
  add_header Content-Security-Policy "frame-ancestors 'self';";      
  expires 0;
}