From 3ee6e3c6ff88cf5e67f96953f8ade4c607edac40 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 25 Sep 2023 00:35:09 +0200 Subject: [PATCH] fix: move error log to stderr globally --- Dockerfile.multiarch | 2 +- overlay/etc/nginx/nginx.conf | 18 +++++++++--------- overlay/usr/local/bin/entrypoint | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Dockerfile.multiarch b/Dockerfile.multiarch index 5914c0f..991f6d8 100644 --- a/Dockerfile.multiarch +++ b/Dockerfile.multiarch @@ -38,7 +38,7 @@ RUN mkdir -p /var/www /etc/nginx-s3 /etc/nginx/conf.d /var/tmp/nginx /var/cache/ touch /run/nginx.pid && \ touch /etc/nginx/conf.d/vhosts.conf && \ chown nginx /run/nginx.pid && \ - chown -R nginx /var/log/nginx /var/tmp/nginx /var/cache/nginx && \ + chown -R nginx /var/tmp/nginx /var/cache/nginx && \ chown -R nginx:nginx /var/www && \ chown -R root:nginx /etc/nginx /etc/nginx/conf.d && \ chmod -R 640 /etc/nginx /etc/nginx/conf.d && \ diff --git a/overlay/etc/nginx/nginx.conf b/overlay/etc/nginx/nginx.conf index da7e4e5..917886e 100644 --- a/overlay/etc/nginx/nginx.conf +++ b/overlay/etc/nginx/nginx.conf @@ -1,21 +1,21 @@ worker_processes 1; pid /var/run/nginx.pid; +error_log stderr error; events { worker_connections 1024; } http { - include /etc/nginx/mime.types; - default_type application/octet-stream; + include /etc/nginx/mime.types; + default_type application/octet-stream; - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - server_tokens off; - access_log off; - error_log /dev/stderr; + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + server_tokens off; + access_log off; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; diff --git a/overlay/usr/local/bin/entrypoint b/overlay/usr/local/bin/entrypoint index 88946ec..1392f37 100755 --- a/overlay/usr/local/bin/entrypoint +++ b/overlay/usr/local/bin/entrypoint @@ -8,12 +8,12 @@ set -eo pipefail start_server() { log_info "Start nginx server" - if ! nginx -q -g 'daemon off;' -t; then + if ! nginx -e stderr -q -g 'daemon off;' -t; then log_error 'Nginx config validation failed, exit' exit 1 fi - exec nginx -g "daemon off;" & + exec nginx -e stderr -g "daemon off;" & PID=$! { @@ -21,7 +21,7 @@ start_server() { inotifywait -rq --timefmt "%F %T" --format "%T [INFO] [$(basename "$0")] %e %f" -e modify,move,create,delete /etc/nginx/ log_info 'Detected nginx config update, run validation' - if ! nginx -q -g 'daemon off;' -t; then + if ! nginx -e stderr -q -g 'daemon off;' -t; then log_warn 'Nginx config validation failed, skip reload' continue fi