Получал
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
Пришлось просто вручную прописать SCRIPT_FILENAME
Вот итоговый конфиг
server {
listen 80 default_server;
server_name localhost;
root /app/src;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location /api {
root /app/src;
index index.php index.html index.htm;
try_files $uri /api/index.php$is_args$args;
location ~ \.php$ {
fastcgi_pass api:9000;
include fastcgi_params;
fastcgi_split_path_info ^(?:\/api\/)(.+\.php)(.*)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /app/src/index.php;
}
}
location / {
proxy_pass http://web:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
break;
}
}