php-fpm 和 nginx 图像和 css 在多容器设置中服务

php-fpm and nginx image and css serving in a multi container setup

所以我们目前正在 Docker-Compose locally 和 Docker-Swarm on prod 中的 1 webserver multiple PHP-FPM 设置,我们开始觉得工作完成了,然后我们 运行 遇到了 php-fpm 的一些问题,当我们想加载一些我们得到的图像时:

NOTICE: Access to the script '/app/DSDPersonnel/test.jpg' has been denied (see security.limit_extensions)

然后我开始谷歌搜索,发现它是 www.confphp-fpm.conf 中的 php fpm 错误,所以我尝试编辑它们。

自从我们 运行 在 docker 上设置此设置后,我尝试了以下解决方案:

ERROR: Passing INI directive through FastCGI: unable to set 'security.limit_extensions'

然后在页面加载后得到相同的结果:

NOTICE: Access to the script '/app/DSDPersonnel/test.jpg' has been denied (see security.limit_extensions)

现在完全没思路了。这是我们的 nginx 配置文件:

location /DSDPersonnel {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass dsd-personnel:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

任何建议都是有用的,但由于多容器设置,我们不想将图像从 php 容器移动到 nginx。

编辑 www.conf 应该可以解决我现在在 php-fpm 7 上测试过的问题,取消注释行

security.limit_extensions = .php .php3 .php4 .php5

并添加 .jpg 扩展名 security.limit_extensions = .php .php3 .php4 .php5 .jpg

或取消注释,并删除 dockerfile 中的任何扩展(注意安全风险):

RUN echo "security.limit.extensions =" >> /usr/local/etc/php-fpm.d/www.conf

(注意您的 www.conf 位置,以及将附加到文件而不是完全覆盖它的 >>)