title: Docker Nginx + PHP-FPM Error Fastcgi Header
body: <p>I am creating a PHP(Phalcon) project, using docker compose. The image is tailored based on the <a href="https://github.com/webdevops/Dockerfile" rel="nofollow noreferrer">webdevops project</a>. In our production, staging, and my own machine, the docker-compose configuration work normally. But there is some error in one of my team machine, despite the similar config, and we are using the same image.</p>
  
  <p>Here is the docker-compose.yml</p>
  
  <pre><code>version: '3'
  
  networks:
    dev_vm:
      external:
        name: dev_vm
  
  services:
    traefik:
      image: traefik:1.6-alpine
      container_name: traefik
      ports:
        - "80:80"
        - "8080:8080"
        - "443:443"
      labels: 
        - traefik.enable=true
        - traefik.frontend.rule=Host:monitor.vm
        - traefik.port=8080
        - traefik.docker.network=dev_vm
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock:ro
        - ./traefik/traefik.toml:/traefik.toml:ro
        - ./traefik/acme:/etc/traefik/acme
      networks:
        - dev_vm
  
    mysql:
      image: mariadb:10.2
      container_name: mysql
      ports:
        - "3306:3306"
      networks:
        - dev_vm
      volumes:
        - ./data/mysql:/docker-entrypoint-initdb.d
        - ./var/lib/mysql:/var/lib/mysql
        - ./conf/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
      env_file:
          - variables.env
  
    phpmyadmin:
      image: phpmyadmin/phpmyadmin:4.7
      container_name: phpmyadmin
      labels:
        - traefik.enable=true
        - traefik.frontend.rule=Host:pma.vm
        - traefik.port=80
        - traefik.docker.network=dev_vm
      depends_on:
        - mysql
      networks:
        dev_vm:
      env_file:
        - variables.env
  
    queue:
      container_name: queue
      image: gamalan/beanstalk-docker:latest
      ports:
        - "11300:11300"
      networks:
        - dev_vm
      volumes:
        - beanstalk:/var/lib/beanstalkd
      env_file:
        - variables.env
  
    bean_console:
      container_name: bean_console
      image: kusmierz/beanstalk-console:latest
      labels:
        - traefik.enable=true
        - traefik.frontend.rule=Host:bean.vm
        - traefik.port=80
        - traefik.docker.network=dev_vm
      networks:
        - dev_vm
      depends_on:
        - queue
      env_file:
        - variables.env
  
    elasticsearch:
      container_name: elasticsearch
      image: docker.elastic.co/elasticsearch/elasticsearch:6.2.4
      environment:
        - "discovery.type=single-node"
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      ulimits:
        memlock:
          soft: -1
          hard: -1
      volumes:
        - esdata1:/usr/share/elasticsearch/data
      ports:
        - 9200:9200
        - 9300:9300
      networks:
        - dev_vm
  
    redis:
      container_name: redis
      image: redis:3.2-alpine
      ports:
        - "6379:6379"
      networks:
        - dev_vm
      volumes:
        - redis:/data
        - ./redis_passwd:/run/secrets/redis-pass
      environment:
        REDIS_PASS_FILE: /run/secrets/redis-pass
      command: [
        "sh", "-c",
        '
         docker-entrypoint.sh
         --requirepass "$$(cat $$REDIS_PASS_FILE)"
        '
      ]
  
    appmain:
      container_name: appmain
      image: gamalan/phalcon-nginx:7.2-dev
      working_dir: /project
      labels:
        - traefik.enable=true
        - traefik.frontend.rule=Host:app.vm
        - traefik.port=80
        - traefik.docker.network=dev_vm
      networks:
        dev_vm:
          aliases:
            - "app.vm"
      volumes:
        - ./application/project:/project
        - ./conf/nginx/location-root.conf:/opt/docker/etc/nginx/vhost.common.d/10-location-root.conf
      #delete unnecessary depend
      depends_on:
        - mysql
        - queue
        - redis
      env_file:
        - app-kirim-main.env
  
  volumes:
    beanstalk:
      driver: local
    redis:
      driver: local
    esdata1:
      driver: local
  </code></pre>
  
  <p>Here are the docker logs from one my team :</p>
  
  <pre><code>-&gt; Executing /opt/docker/provision/entrypoint.d/05-permissions.sh
  -&gt; Executing /opt/docker/provision/entrypoint.d/20-nginx.sh
  -&gt; Executing /opt/docker/provision/entrypoint.d/20-php-fpm.sh
  -&gt; Executing /opt/docker/provision/entrypoint.d/20-php.sh
  -&gt; Executing /opt/docker/provision/entrypoint.d/fix-permission.sh
  -&gt; Executing /opt/docker/bin/service.d/supervisor.d//10-init.sh
  2018-11-27 02:43:50,891 CRIT Set uid to user 0
  2018-11-27 02:43:50,892 INFO Included extra file "/opt/docker/etc/supervisor.d/cron.conf" during parsing
  2018-11-27 02:43:50,892 INFO Included extra file "/opt/docker/etc/supervisor.d/dnsmasq.conf" during parsing
  2018-11-27 02:43:50,892 INFO Included extra file "/opt/docker/etc/supervisor.d/nginx.conf" during parsing
  2018-11-27 02:43:50,892 INFO Included extra file "/opt/docker/etc/supervisor.d/php-fpm.conf" during parsing
  2018-11-27 02:43:50,892 INFO Included extra file "/opt/docker/etc/supervisor.d/postfix.conf" during parsing
  2018-11-27 02:43:50,892 INFO Included extra file "/opt/docker/etc/supervisor.d/ssh.conf" during parsing
  2018-11-27 02:43:50,892 INFO Included extra file "/opt/docker/etc/supervisor.d/syslog.conf" during parsing
  2018-11-27 02:43:50,899 INFO RPC interface 'supervisor' initialized
  2018-11-27 02:43:50,900 INFO supervisord started with pid 1
  2018-11-27 02:43:51,903 INFO spawned: 'syslogd' with pid 50
  2018-11-27 02:43:51,904 INFO spawned: 'nginxd' with pid 51
  2018-11-27 02:43:51,907 INFO spawned: 'php-fpmd' with pid 52
  2018-11-27 02:43:51,909 INFO spawned: 'crond' with pid 53
  -&gt; Executing /opt/docker/bin/service.d/syslog-ng.d//10-init.sh
  2018-11-27 02:43:51,912 INFO success: nginxd entered RUNNING state, process has stayed up for &gt; than 0 seconds (startsecs)
  2018-11-27 02:43:51,912 INFO success: php-fpmd entered RUNNING state, process has stayed up for &gt; than 0 seconds (startsecs)
  2018-11-27 02:43:51,912 INFO success: crond entered RUNNING state, process has stayed up for &gt; than 0 seconds (startsecs)
  -&gt; Executing /opt/docker/bin/service.d/nginx.d//10-init.sh
  -&gt; Executing /opt/docker/bin/service.d/php-fpm.d//10-init.sh
  -&gt; Executing /opt/docker/bin/service.d/cron.d//10-init.sh
  Setting php-fpm user to application
  [SYSLOG] syslog-ng[50]: syslog-ng starting up; version='3.8.1'
  [SYSLOG] cron[53]: (CRON) INFO (pidfile fd = 3)
  [SYSLOG] cron[53]: (CRON) INFO (Skipping @reboot jobs -- not system startup)
  [27-Nov-2018 02:43:51] NOTICE: fpm is running, pid 52
  [27-Nov-2018 02:43:51] NOTICE: ready to handle connections
  2018-11-27 02:43:52,994 INFO success: syslogd entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs)
  2018/11/27 02:44:04 [error] 69#69: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
  [27-Nov-2018 02:44:04] WARNING: [pool www] child 73 exited on signal 4 (SIGILL - core dumped) after 12.033304 seconds from start
  [27-Nov-2018 02:44:04] NOTICE: [pool www] child 89 started
  127.0.0.1 - - [27/Nov/2018:02:44:04 +0000] "GET / HTTP/1.1" 502 173 "-" "curl/7.52.1"
  2018/11/27 02:44:27 [error] 69#69: *3 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
  127.0.0.1 - - [27/Nov/2018:02:44:27 +0000] "GET / HTTP/1.1" 502 173 "-" "curl/7.52.1"
  [27-Nov-2018 02:44:27] WARNING: [pool www] child 74 exited on signal 4 (SIGILL - core dumped) after 35.759019 seconds from start
  [27-Nov-2018 02:44:27] NOTICE: [pool www] child 92 started
  2018/11/27 02:45:50 [error] 69#69: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /index.php?_url=/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
  127.0.0.1 - - [27/Nov/2018:02:45:50 +0000] "GET /index.php?_url=/ HTTP/1.1" 502 173 "-" "curl/7.52.1"
  [27-Nov-2018 02:45:50] WARNING: [pool www] child 88 exited on signal 4 (SIGILL - core dumped) after 106.809806 seconds from start
  [27-Nov-2018 02:45:50] NOTICE: [pool www] child 152 started
  2018/11/27 02:45:56 [error] 69#69: *7 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /index.php?_url=dashboard HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
  127.0.0.1 - - [27/Nov/2018:02:45:56 +0000] "GET /index.php?_url=dashboard HTTP/1.1" 502 173 "-" "curl/7.52.1"
  [27-Nov-2018 02:45:56] WARNING: [pool www] child 89 exited on signal 4 (SIGILL - core dumped) after 112.188027 seconds from start
  [27-Nov-2018 02:45:56] NOTICE: [pool www] child 155 started
  127.0.0.1 - - [27/Nov/2018:02:46:34 +0000] "GET /maintenance.html HTTP/1.1" 200 2178 "-" "curl/7.52.1"
  2018/11/27 02:47:11 [error] 69#69: *10 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"
  [27-Nov-2018 02:47:11] WARNING: [pool www] child 92 exited on signal 4 (SIGILL - core dumped) after 163.832662 seconds from start
  127.0.0.1 - - [27/Nov/2018:02:47:11 +0000] "GET / HTTP/1.1" 502 173 "-" "curl/7.52.1"
  [27-Nov-2018 02:47:11] NOTICE: [pool www] child 160 started
  [php-fpm:access] 127.0.0.1 -  27/Nov/2018:02:48:27 +0000 "GET /info.php" 200 /project/public/info.php 914.436 2048 10.94%
  127.0.0.1 - - [27/Nov/2018:02:48:27 +0000] "GET /info.php HTTP/1.1" 200 132955 "-" "curl/7.52.1"
  [php-fpm:access] 127.0.0.1 -  27/Nov/2018:02:48:47 +0000 "GET /info.php" 200 /project/public/info.php 60.519 2048 99.14%
  172.22.0.4 - - [27/Nov/2018:02:48:47 +0000] "GET /info.php HTTP/1.1" 200 33154 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
  </code></pre>
  
  <p>At first, I assume it was a memory problem, but when I check, the machine has enough free memory. Also, the phpMyAdmin and other container are working normally. If it was the code, then it will definitely break in other environments too, yet it doesn't break, even in our staging or prod server. </p>
  
  <p>So, currently, I am stumped, what exactly the cause. Because this same configuration is have been tested in ArchLinux, Ubuntu 18.04, CentOS 7, and Windows 10, and it working normally, but somehow for a few other, it doesn't work as expected. Can anybody help me?</p>