Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Elastic Beanstalk-自定义Nginx配置文件-PHP Web应用程序_Php_Amazon Web Services_Nginx_Amazon Elastic Beanstalk - Fatal编程技术网

Elastic Beanstalk-自定义Nginx配置文件-PHP Web应用程序

Elastic Beanstalk-自定义Nginx配置文件-PHP Web应用程序,php,amazon-web-services,nginx,amazon-elastic-beanstalk,Php,Amazon Web Services,Nginx,Amazon Elastic Beanstalk,beanstalk文档不清楚在部署PHP应用程序时如何以及什么是定制nginx配置的最佳方法 我尝试了多种方法,包括文件/etc/nginx/conf.d/01 security.conf,如下所示: files: /etc/nginx/conf.d/01-security.conf: mode: “000644” owner: root group: root content: | add_header X-Frame-Options "SAMEORIGIN" alwa

beanstalk文档不清楚在部署PHP应用程序时如何以及什么是定制nginx配置的最佳方法

我尝试了多种方法,包括文件/etc/nginx/conf.d/01 security.conf,如下所示:

files:
/etc/nginx/conf.d/01-security.conf:
mode: “000644”
owner: root
group: root
content: |
  add_header X-Frame-Options "SAMEORIGIN" always ;
  add_header X-XSS-Protection "1; mode=block" always;
  add_header X-Content-Type-Options "nosniff" always;
  add_header Referrer-Policy "no-referrer-when-downgrade" always;
  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" 
  always;
  add_header X-Cache-Status $upstream_cache_status;
我尝试过其他选择,但似乎没有一个可行。我有点困惑,因为beanstalk没有给出任何关于如何为PHP实现的明确方向?我见过人们使用不同的策略,其中一些是在2018年、2017年


我可以使用container_命令替换配置,然后重新启动nginx,但有没有办法添加更多配置文件或修改原始配置文件?

您的
/etc/nginx/conf.d/01 security.conf
不起作用的一个可能原因是您使用的是Amazon Linux 2(AL2)。但是,该设置文件适用于基于AL1的旧EB平台

对于AL2,nginx设置应该在
.platform/nginx/conf.d/
中,而不是在
.ebextensions
中,如中所示

因此,您可以拥有以下内容的
.platform/nginx/conf.d/myconfig.conf

add_header X-Frame-Options "SAMEORIGIN" always ;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" 
always;
add_header X-Cache-Status $upstream_cache_status;
以上是一个例子。我无法验证这些设置是否实际有效,但在我看来,您使用的是AL2,而不是AL1。在这种情况下,您为
nginx
config文件使用了错误的文件夹