【发布时间】:2021-04-08 10:13:37
【问题描述】:
我正在尝试在 AWS Fargate 中安装 nginx 和 php-fpm docker 映像,但没有任何成功的选项,我看到的是 nginx 容器无法将流量路由到 php 容器或 php 容器无法从中读取文件EFS 文件系统。
我的 EFS 文件系统在根文件夹中保存示例 index.html 和 index.php 文件,并且此 EFS 与从 AWS 任务定义创建向导中的卷挂载的两个容器 nginx 和 php-fpm 共享。 当我导航到 ELB 友好的 DNS 名称时,我可以成功加载 index.html 页面但不是 index.php 页面我在从上游读取响应标头时收到“主脚本未知”,客户端:xxxx,服务器:* .amazonaws.com,请求:“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 地址硬核 fastcgi 上游和 server_name 字段,并且在 pgp-fpm 容器中的 www.conf 文件中监听 = phpcontainer:9000 的 IP 地址,这在本地解决了问题,但在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;
}
}
【问题讨论】:
标签: php amazon-web-services docker nginx aws-fargate