Closed9

Laravel9でFargate構築したいが、nginxの起動がうまくいかない

Laravel9をFargateを用いて構築する際にエラーが発生

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2022/09/24 19:56:30 [emerg] 1#1: "user" directive is not allowed here in /etc/nginx/conf.d/nginx.conf:1
nginx: [emerg] "user" directive is not allowed here in /etc/nginx/conf.d/nginx.conf:1

現状

localhostでは正しく動くが、ECSのタスク起動時にエラーになる

fastcgi_pass 127.0.0.1:9000;

にするとlocalでは表示されない

ECSのタスクは起動したが、file not foundになる

fastcgi_pass localhost:9000;

default.confを上記のように修正すると、タスクの起動はできるようになった

しかし、以下のエラーが発生している

  • localhostではサービスにアクセスできない
  • DNS名でアクセスすると、file not found になる
  • 以下のエラー文
[error] 10#10: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.0.1.60, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "10.0.0.196"
 
[24/Sep/2022:21:04:05 +0900] "GET / HTTP/1.1" 404 27 "-" "ELB-HealthChecker/2.0"

[error] 10#10: *26 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.0.1.60, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "10.0.0.196"
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

localでは以下のエラー

2022/09/24 21:12:06 [error] 11#11: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.29.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8082"
172.29.0.1 - - [24/Sep/2022:21:12:06 +0900] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
2022/09/24 21:12:06 [error] 11#11: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.29.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8082"
172.29.0.1 - - [24/Sep/2022:21:12:06 +0900] "GET / HTTP/1.1"  "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/ (KHTML, like Gecko) Chrome/105.0.0.0 Safari/"
2022/09/24 21:12:07 [error] 11#11: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.29.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8082"

172.29.0.1 - - [24/Sep/2022:21:12:07 +0900] "GET / HTTP/1.1"  "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/6 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
172.29.0.1 - - [24/Sep/2022:21:12:07 +0900] "GET / HTTP/1.1"  "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/5 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/"
2022/09/24 21:12:07 [error] 11#11: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.29.0.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8082"

AWS構築を優先して、PFの中身は空の状態でやってみるか

→うまくいかないので、0からやる

このスクラップは2ヶ月前にクローズされました
ログインするとコメントできます