[英]ZF: nginx to serve images/css/js/files and apache to serve .php
[英]Nginx cannot serve css or js
我剛剛開始使用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
文件添加到具有修改的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
我還看到其他用戶通過在php.ini
包含cgi.fix_pathinfo=1
來解決此問題。 但是,這不能解決原始問題。
如果有幫助,我在這里包括了我的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;
}
}
我也曾嘗試按照此處所示修改www.conf
文件,但是沒有這樣的/etc/php*
路徑。
干杯!
通過刪除/usr/local/etc/php-fpm.d/www.conf
security.limit_extensions =
所有條目來解決此問題。
我找不到文件的原因是因為它不存在於我的nginx2
容器中,但是位於我的php2
容器中。 我在php2
容器中搜索它。 我的理解是,由於文件是靜態的,因此最好由nginx服務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.