Nginx – php-fpm status page not found on docker

dockernginxphp-fpm

I Have two docker containers for php-fpm and nginx, i run it with docker-compose.yml file, but i try to setup the status page of my php-fpm and it not found.

i acces to http://localhost/status url and it show File not found message.

i tryed too many configurations but it not works.

my direcoty tree is it:

C:.
│   docker-compose.yml
│
├───app
│       index.php
│
├───fpmConf
│       www.conf
│
├───nginxConf
│       default.conf
│
└───phpConf
        php.ini

my docker-compose.yml file is:

version: '3'
services:

  php:
    image: php:7.2-fpm
    container_name: php_app
    restart: always
    environment:
      TZ: America/Mexico_City
    ports:
      - 9000:9000
    volumes:
      - ./app:/var/www/html
      - ./phpConf/php.ini:/usr/local/etc/php/conf.d/custom.ini
    tty: true

  nginx:
    image: nginx:latest
    container_name: nginx_proxy
    restart: always
    environment:
      TZ: America/Mexico_City
    ports:
      - 80:80
    links:
      - php
    volumes:
      - ./app:/var/www/html
      - ./nginxConf:/etc/nginx/conf.d
      - ./fpmConf/www.conf:/etc/php-fpm.d/www.conf
    depends_on:
      - php
    tty: true

my www.conf file is:

user = www
listen = php:9000

pm = ondemand
pm.max_children = 50
pm.max_requests = 500
pm.process_idle_timeout = 10s
pm.status_path = /status

ping.path = /ping

slowlog = /data/logs/php-fpm-slow.log
request_slowlog_timeout = 60
catch_workers_output = yes

env[TMPDIR] = /data/tmp/php

include = /data/conf/php-fpm-www-*.conf

my default.conf file is:

upstream php-upstream {
    server php:9000;
}

server {
    server_tokens off; 

    charset utf-8;
    client_max_body_size 128M;

    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;

    listen 80;
    server_name localhost;


    # set caching header for static files
    location ~* \.(jpg|jpeg|gif|png|css|js|ico|svg|ttf|webp)$ {
         access_log          off;
         log_not_found       off;
         expires             30d;
    }

    root /var/www/html;
    index index.php;

    location / {

            try_files $uri $uri/ /index.php$is_args$args;

            location ~ \.php$ {
                fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                if (!-f $document_root$fastcgi_script_name) {
                return 404;
            }

            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_buffers 16 16k;
            fastcgi_buffer_size 32k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 300;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            fastcgi_pass_header Set-Cookie;
            fastcgi_pass_header Cookie;
            fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

        }
    }

    location /status {
        access_log off;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass php-upstream;
        fastcgi_index status.html;
    }


}

my php.ini file is:

date.timezone = "America/Mexico_City"

default_charset = "utf-8";
mbstring.internal_encoding=utf-8;
mbstring.http_output=UTF-8;
mbstring.encoding_translation=On;

session.use_cookies = 1
session.name = PHPSESSID
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = alocalhost
session.serialize_handler = php

session.gc_maxlifetime = 86400
max_input_vars = 1000000

Best Answer

I resolved it copying from container the www.conf file to my host:

docker cp -a php_app:/usr/local/etc/php-fpm.d/www.conf ./www.conf

Then i uncomment this line and share these new www.conf file with docker:

pm.status_path = /status

This is my new docker-compose.yml with the new volume with the www.conf ./status/www.conf:/usr/local/etc/php-fpm.d/www.conf :

version: '3'
services:

  php:
    image: php:7.2-fpm
    container_name: php_app
    restart: always
    environment:
      TZ: America/Mexico_City
    ports:
      - 9000:9000
    volumes:
      - ./app:/var/www/html
      - ./phpConf/php.ini:/usr/local/etc/php/conf.d/custom.ini
      - ./status/www.conf:/usr/local/etc/php-fpm.d/www.conf
    tty: true

  nginx:
    image: nginx:latest
    container_name: nginx_proxy
    restart: always
    environment:
      TZ: America/Mexico_City
    ports:
      - 80:80
    links:
      - php
    volumes:
      - ./app:/var/www/html
      - ./nginxConf:/etc/nginx/conf.d
      - ./fpmConf/www.conf:/etc/php-fpm.d/www.conf
    depends_on:
      - php
    tty: true