Кажется, я не могу отключить журналы доступа из вывода nginx на stdout докера (отображается в docker logs <container>
)
Это мой Dockerfile
FROM php:7.3.11-fpm-alpine as base
WORKDIR /var/www
# Use the default production configuration
RUN cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
#Â Install dependencies
RUN set -xe \
&& apk add --no-cache bash icu-dev \
&& apk add --no-cache nginx supervisor curl
# Configure nginx
COPY nginx.conf /etc/nginx/nginx.conf
# Configure supervisord
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Make sure files/folders needed by the processes are accessable when they run under the nobody user
RUN chown -R nobody.nobody /run && \
chown -R nobody.nobody /var/lib/nginx && \
chown -R nobody.nobody /var/tmp/nginx && \
chown -R nobody.nobody /var/log/nginx
# Setup document root
RUN mkdir -p /var/www/html/public
WORKDIR /var/www/html
RUN echo "<?php echo 'OK';" >> /var/www/html/public/healthcheck.php
USER nobody
# Expose the port nginx is reachable on
EXPOSE 8080
# Let supervisord start nginx & php-fpm
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
Это nginx.conf
worker_processes 1;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log off;
proxy_buffers 16 16k;
proxy_buffer_size 16k;
keepalive_timeout 65;
server {
listen [::]:8080 default_server;
listen 8080 default_server;
server_name _;
sendfile off;
root /var/www/html/public;
index index.php index.html;
location = /healthcheck.php {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
}
Это supervisord.conf
[supervisord]
nodaemon=true
logfile=/dev/null
logfile_maxbytes=0
pidfile=/run/supervisord.pid
[program:php-fpm]
command=php-fpm -F
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=false
startretries=0
[program:nginx]
command=nginx -g 'daemon off;'
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
autorestart=false
startretries=0
но все еще получаю результат, я не хочу
2019-12-16 11:04:30,107 INFO supervisord started with pid 1
2019-12-16 11:04:31,110 INFO spawned: 'nginx' with pid 7
2019-12-16 11:04:31,122 INFO spawned: 'php-fpm' with pid 8
[16-Dec-2019 11:04:31] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[16-Dec-2019 11:04:31] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[16-Dec-2019 11:04:31] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[16-Dec-2019 11:04:31] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
[16-Dec-2019 11:04:31] NOTICE: fpm is running, pid 8
[16-Dec-2019 11:04:31] NOTICE: ready to handle connections
2019-12-16 11:04:32,209 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-12-16 11:04:32,211 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
127.0.0.1 - 16/Dec/2019:11:04:34 +0000 "GET /healthcheck.php" 200
127.0.0.1 - 16/Dec/2019:11:04:34 +0000 "GET /healthcheck.php" 200
127.0.0.1 - 16/Dec/2019:11:04:34 +0000 "GET /healthcheck.php" 200
Как отключить журнал доступа nginx с помощью Docker и супервизора?
Мне удалось выяснить, в чем проблема - это был журнал доступа к php-fpm
который регистрировал эти запросы и фактически nginx
не ведется журнал вообще. Чтобы узнать, что записывается, что я включил отладочную запись supervisord
, это дало мне результат ниже
2020-01-06 11:57:27,790 DEBG 'php-fpm' stderr output:
127.0.0.1 - 06/Jan/2020:11:57:27 +0000 "GET /healthcheck.php" 200
2020-01-06 11:57:27,790 DEBG 'php-fpm' stderr output:
127.0.0.1 - 06/Jan/2020:11:57:27 +0000 "GET /healthcheck.php" 200
2020-01-06 11:57:27,792 DEBG 'nginx' stdout output:
172.17.0.1 - - [06/Jan/2020:11:57:27 +0000] "GET /healthcheck.php HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0" "-"
2020-01-06 11:57:27,792 DEBG 'nginx' stdout output:
172.17.0.1 - - [06/Jan/2020:11:57:27 +0000] "GET /healthcheck.php HTTP/1.1" 200 12 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0" "-"
Затем я обновил конфигурацию (по умолчанию php-fpm
образ докера выводит журнал доступа к stdout
) и конфиг для nginx
начал работать как положено