Skip to content

fix(php-fpm-nginx): forward nginx logs to stdout/stderr#2

Merged
sylvesterdamgaard merged 3 commits into
mainfrom
fix/nginx-logs-to-stdout
May 7, 2026
Merged

fix(php-fpm-nginx): forward nginx logs to stdout/stderr#2
sylvesterdamgaard merged 3 commits into
mainfrom
fix/nginx-logs-to-stdout

Conversation

@sylvesterdamgaard
Copy link
Copy Markdown
Contributor

Problem

The `php-fpm-nginx` image installs nginx with Debian's stock `/etc/nginx/nginx.conf`, which writes:

```
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
```

Inside a container these are regular files in the overlay filesystem. They never reach `docker logs` / `kubectl logs`. The standalone `nginx` image already does the symlinks — `php-fpm-nginx` just missed them.

Concrete symptom (encountered while running id on this baseimage):

  • `kubectl logs ` shows cbox-init's own startup messages
  • No access lines, no warnings, no upstream errors from nginx
  • PHP-FPM master output makes it through (catch_workers_output + error_log = /proc/self/fd/2) but nginx is silent

Fix

Symlink the two log files to `/dev/stdout` and `/dev/stderr` at build time:

```dockerfile
RUN mkdir -p /etc/nginx/conf.d /var/log/nginx /run/nginx && \
chown -R www-data:www-data /var/log/nginx /run/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
```

The existing nginx config keeps writing to `/var/log/nginx/access.log` and `/var/log/nginx/error.log`; those paths now resolve to the container's stdout/stderr. This is the same convention Docker's official nginx image uses, and is what the standalone `nginx` image in this repo already does.

Applied to all 8 stages: slim/standard/chromium/dev × root/rootless.

Test plan

  • Build a fresh `8.5-bookworm` tag locally
  • Run a Laravel app, hit a route, verify `docker logs` shows the nginx access line
  • Trigger an upstream error (make fpm fail), verify the nginx error appears in `docker logs`
  • Confirm rootless variants still start cleanly (write access to `/var/log/nginx/` is via the symlinks, owned by root for /dev/stdout — but the symlink itself is fine)

sylvesterdamgaard and others added 3 commits May 7, 2026 10:31
The php-fpm-nginx image installs nginx with Debian's stock
/etc/nginx/nginx.conf, which writes:

  access_log /var/log/nginx/access.log;
  error_log  /var/log/nginx/error.log warn;

In a container these are regular files inside the overlay fs and
never reach `docker logs` / `kubectl logs`. The standalone nginx
image already symlinks them to /dev/stdout and /dev/stderr — this
brings php-fpm-nginx in line with the same convention.

Symptom: an operator running id (Cbox · ID, a Laravel app) on
this baseimage saw cbox-init's own startup messages in
`kubectl logs` but nothing from nginx (no access lines, no
warnings, no upstream errors) and only fragments from PHP-FPM.

Symlinking at build time means the existing config keeps writing
to /var/log/nginx/access.log + error.log, but those paths now
resolve to the container's stdout/stderr.

Applied to all 8 stages (slim/standard/chromium/dev × root/rootless).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sylvesterdamgaard sylvesterdamgaard merged commit 1292c3f into main May 7, 2026
3 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant