我刚刚开始使用Docker,并且在配置容器以正确提供网页方面存在问题。问题如下:
nginx2 | 2018/03/17 19:01:19 [error] 8#8: *8 FastCGI sent in stderr: "Access to the script '/var/www/sites/public/res/styles.css' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 172.21.0.1, server: , request: "GET /res/styles.css HTTP/1.1", upstream: "fastcgi://172.21.0.3:9000", host: "localhost:8080", referrer: "http://localhost:8080/"
nginx2 | 172.21.0.1 - - [17/Mar/2018:19:01:19 +0000] "GET /res/styles.css HTTP/1.1" 403 25 "http://localhost:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36" "-"
我尝试将自己的自定义php-fpm.conf
文件添加到容器中,其中包含here所示的修改后的security.limit_extensions
参数,但这会导致以下错误
php2 | [17-Mar-2018 19:49:31] ERROR: [/usr/local/etc/php-fpm.conf:1] value is NULL for a ZEND_INI_PARSER_ENTRY
php2 | [17-Mar-2018 19:49:31] ERROR: failed to load configuration file '/usr/local/etc/php-fpm.conf'
php2 | [17-Mar-2018 19:49:31] ERROR: FPM initialization failed
php2 exited with code 78
我还看到其他用户通过在cgi.fix_pathinfo=1
中添加php.ini
来解决此问题。但是,这并没有解决原来的问题。
如果它有用,我在这里包含了我的nginx配置
server{
# listen 80 default_server;
index index.php index.html;
# server_name localhost;
root /var/www/sites/public;
location / {
# root /var/www/sites/public;
try_files $uri $uri/ /index.php;
}
location ~ /res/ {
fastcgi_intercept_errors on;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass php2:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ \.php$ {
#include fastcgi.conf;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php2:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
我还尝试按照here修改www.conf
文件但是没有这样的/etc/php*
路径。
干杯!
答案 0 :(得分:0)
通过删除security.limit_extensions =
中的/usr/local/etc/php-fpm.d/www.conf
的所有条目来解决该问题。
我无法找到该文件的原因是因为它不存在于我的nginx2
容器中,而是位于我的php2
容器中。我在我的php2
容器中搜索它。我的理解是,由于文件是静态的,因此最好由nginx提供。