Title says it all. Prior to installing composer with a “command” in my compose.yml file
my PHP and NGinX stack was working fine. phpinfo would display on my test page. Now I just get a 502 bad gateway error. If I comment out the “command” in my .yml file it works again.
NGinX .conf file looks like this:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name localhost;
root /app;
index index.php index.html;
location / {
fastcgi_buffers 8 16k; # increase the buffer size for PHP-FTP
fastcgi_buffer_size 32k; # increase the buffer size for PHP-FTP
fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
try_files $uri $uri/ /index.php?$args;
}
location ~* .php$ {
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
# Logs for Nginx access and errors
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# deny access to .htaccess/.htpasswd files
location ~ /.ht {
deny all;
}
}
compose.yml file looks like this:
version: '3.8'
services:
NGinX:
image: nginx:latest
container_name: NGinX
hostname: NGinX
security_opt:
- no-new-privileges:true
ports:
- 6080:80/tcp
- 6443:443/tcp
dns:
- 8.8.8.8
- 1.1.1.1
environment:
- PUID=1000
- PGID=100
- TZ=Europe/London
- UMASK=022
volumes:
- /volume1/docker/WebDev/NGinX/nginx.conf:/etc/nginx/conf.d/nginx.conf
- /volume1/docker/WebDev/NGinX/Logs:/var/log/nginx
- /volume1/docker/WebDev/WWW:/app
restart: unless-stopped
depends_on:
- php
php:
build:
context: .
dockerfile: PHP.dockerfile
tty: true
container_name: PHP
hostname: PHP
security_opt:
- no-new-privileges:true
ports:
- 9000:9000
environment:
- PUID=1000
- PGID=100
- TZ=Europe/London
- UMASK=022
volumes:
- /volume1/docker/WebDev/WWW:/app
- /volume1/docker/WebDev/PHP/local-php.ini:/usr/local/etc/php/conf.d/local.ini
# run composer install command here instead of in the dockerfile to avoid volume mounting overwriting the vendor folder
command: composer run-script serve
restart: unless-stopped
NGinX error log:
2024/07/20 12:48:32 [error] 23#23: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.64.1, server: localhost, request: “GET / HTTP/1.1”, upstream: “fastcgi://192.168.64.2:9000”, host: “192.168.1.152:6080”
2024/07/20 12:48:32 [error] 23#23: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.64.1, server: localhost, request: “GET /favicon.ico HTTP/1.1”, upstream: “fastcgi://192.168.64.2:9000”, host: “192.168.1.152:6080”, referrer: “http://192.168.1.152:6080/”