我已经将这两个 docker 容器连接到网络:
两个容器都可以访问包含应用程序文件的本地目录。
我的 NGINX 配置:
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /usr/share/nginx/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
}
Run Code Online (Sandbox Code Playgroud)
尝试访问该站点时,浏览器显示“找不到文件。”。
NGINX 容器日志:
FastCGI 在 stderr 中发送:从上游读取响应标头时“主脚本未知”
PHP-FPM容器日志:
“获取/index.php”404
你能指点我一个方向吗?我迷路了。
NGINX 容器可以看到该文件存在于,/usr/share/nginx/html/index.php否则该try_files语句将生成 404 响应而不是 PHP-FPM。
SCRIPT_FILENAME因此 PHP-FPM 容器已收到设置为 的请求,/usr/share/nginx/html/index.php但 PHP 无法使用该路径名查看该文件。
正如您的评论所确认的,这是两个容器之间的路径名路由的差异。
| 归档时间: |
|
| 查看次数: |
2635 次 |
| 最近记录: |