![](/img/trans.png)
[英]error 28105#0: *1 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream
[英]FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream
I am trying to install nginx and php-fpm docker images in AWS Fargate without any success running out of options, what I see is either the nginx container unable to route the traffic to php container or php container unable to read files from EFS file system .
我有 EFS 文件系统在根文件夹中保存示例 index.html 和 index.php 文件,并且此 EFS 与两个容器共享 nginx 和 php-fpm 从 AWS 创建卷中的向导创建 when I navigate to the ELB friendly DNS name I can successfully load index.html page but not index.php page I get "Primary script unknown" while reading response header from upstream, client: xxxx, server: *.amazonaws.com, request :“GET /index.php HTTP/1.1”,上游:“fastcgi://127.0.0.1:9000”。
将上游值更改为 php:9000; 或 127.0.0.1:9000; 或解析器 127.0.0.11 他们都没有工作。
我在本地遇到了同样的错误,但是如果我使用 default.conf 中的实际 IP 地址和 pgp-fpm 容器中 www.conf 文件中的 phpcontainer:9000 的实际 IP 地址硬核 fastcgi upstream 和 server_name 字段,这在本地解决了问题,但在 AWS fargate重新启动容器后,IP 的所有方式都会发生变化,任何建议表示赞赏。
server {
listen 80;
#root /usr/share/nginx/html;
#local testing for docker-compose up
root /php;
index index.php index.html index.htm;
#server_name *.amazonaws.com;
server_name x.x.x.x; #local testing
#set $upstream 127.0.0.1:9000;
set $upstream x.x.x.x:9000; #local testing
location / {
try_files $uri $uri/ =404;
}
location /dataroot/ {
internal;
alias /usr/share/nginx/html/moodledata/;
}
location ~ ^(.+\.php)(.*)$ {
#root /usr/share/nginx/html;
#local testing
root /php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
fastcgi_pass $upstream;
include /etc/nginx/mime.types;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
尝试多种组合后终于找出了问题,它是由根路径引起的,每个容器 nginx (/usr/shr/nginx/html) 和 php (/var/www/html) 都不同....错误消息没有帮助在 php 和 linux 世界工作的新手。
将 nginx 根路径更改为 /var/www/html 与 php-fpm 容器 /var/www/html 相同后,问题已解决,当然,如果您访问 EFS 卷挂载,则必须注意权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.