Reputation: 91
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.
I have EFS file system holding sample index.html and index.php files in root folder and this EFS is shared with two containers nginx and php-fpm mounted from volumes in AWS Task definition creation wizard. 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: x.x.x.x, server: *.amazonaws.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000".
Changed upstream value to php:9000; or 127.0.0.1:9000; or resolver 127.0.0.11 none of them worked.
I got same error locally but if I hardcore fastcgi upstream and server_name fields with actual IP address in default.conf and listen=ipaddress of phpcontainer:9000 in www.conf file in pgp-fpm container this resolved the issue locally but in AWS fargate the IP's all ways change after restarting container any advise appreciated.
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;
}
}
Upvotes: 0
Views: 3089
Reputation: 91
Finally figured out the issue after trying multiple combinations, its causing from root path which is different to each container nginx (/usr/shr/nginx/html) and php (/var/www/html)....the error message doesnt help for newbies working in php and linux world.
After changing the nginx root path as /var/www/html same as php-fpm container /var/www/html the issue was resolved of course the permissions has to be taken care of if your accessing the EFS volume mounts.
Upvotes: 0