Skip to content

fix: nginx worker processes should run as www-data#78

Merged
AaronFeledy merged 8 commits into
mainfrom
fix/nginx-worker-user
Feb 20, 2026
Merged

fix: nginx worker processes should run as www-data#78
AaronFeledy merged 8 commits into
mainfrom
fix/nginx-worker-user

Conversation

@AaronFeledy
Copy link
Copy Markdown
Member

@AaronFeledy AaronFeledy commented Feb 19, 2026

Problem

The Bitnami nginx image runs worker processes as daemon by default. When used with Drupal (or any PHP app), files created by PHP are owned by www-data. If those files have restrictive permissions (e.g., 750/640), nginx workers running as daemon get 403 errors trying to serve CSS/JS/etc.

Test

This PR first adds a worker-user example test that:

  1. Creates files owned by www-data with 750/640 permissions
  2. Verifies nginx worker processes run as www-data
  3. Verifies nginx can serve those files (200, not 403)

This test should FAIL on the initial push to prove the bug exists.

Fix

Coming in a follow-up commit after CI confirms the failure.

References

Fixes #79


Note

Medium Risk
Changes the nginx container startup behavior by patching Bitnami scripts to run workers as www-data, which could impact permissions and runtime behavior across environments. Adds a targeted example test to validate file-serving and process ownership, reducing regression risk but still touching core startup paths.

Overview
Ensures nginx worker processes run as www-data by patching Bitnami’s nginx-env.sh during config/launch.sh before the entrypoint executes, preventing 403s when serving files created by PHP with restrictive permissions.

Extends the 1.29 example to install procps, create a www-data-owned test file with 750/640 perms, and documents verification commands to confirm worker user and successful serving (HTTP 200). Also updates Netlify link-check config to ignore hub.docker.com and includes a package-lock.json metadata-only adjustment.

Written by Cursor Bugbot for commit cc7b549. This will update automatically on new commits. Configure here.

Adds an example that creates files owned by www-data with 750/640
permissions and verifies nginx can serve them. This will fail because
the Bitnami nginx image runs worker processes as 'daemon' instead of
'www-data'.

See: https://github.com/lando/drupal/issues/124
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 19, 2026

Deploy Preview for lando-nginx ready!

Name Link
🔨 Latest commit cc7b549
🔍 Latest deploy log https://app.netlify.com/projects/lando-nginx/deploys/69976d324db2de00088024bb
😎 Deploy Preview https://deploy-preview-78--lando-nginx.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 77 (🔴 down 13 from production)
Accessibility: 98 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

The Bitnami nginx image uses NGINX_DAEMON_USER to configure the worker
process user. Previously set to 'root', which caused the Bitnami
entrypoint to fall back to 'daemon'. This mismatch means nginx workers
can't read files owned by www-data with restrictive permissions (750/640),
resulting in 403 errors on CSS/JS assets in Drupal and other PHP apps.

Fixes: https://github.com/lando/drupal/issues/124
No need for a separate example — bake the www-data assertions into the
1.29 test that already runs in CI.
This plugin has been crashing every deploy-preview build since at least
Dec 2025. Removing it so PR previews actually deploy again.
Docker Hub responses lack Content-Type headers, causing
netlify-plugin-checklinks to fail with content-type-missing errors.
The links themselves are valid — Docker Hub just doesn't set the header.

Fixes deploy-preview builds that have been failing since Dec 2025.
@AaronFeledy AaronFeledy force-pushed the fix/nginx-worker-user branch from c863432 to 6704f30 Compare February 19, 2026 19:58
The actual worker user is controlled by the 'user' directive in
nginx.conf, not the NGINX_DAEMON_USER env var (which gets overwritten
by Bitnami's nginx-env.sh anyway). Changed from 'root root' to
'www-data www-data' so nginx workers can read files created by PHP.

Reverts the env var change (irrelevant) and fixes the real source.

Fixes: https://github.com/lando/drupal/issues/124
Bitnami's nginx-env.sh hardcodes NGINX_DAEMON_USER='daemon', overwriting
any env var Lando sets. The entrypoint then rewrites the 'user' directive
in nginx.conf with this value. The only reliable fix is patching
nginx-env.sh before the entrypoint runs.

Added sed commands to launch.sh to replace 'daemon' with 'www-data'
in nginx-env.sh before the Bitnami entrypoint sources it.

Fixes: https://github.com/lando/drupal/issues/124
@AaronFeledy AaronFeledy merged commit 80fbfeb into main Feb 20, 2026
40 checks passed
@AaronFeledy AaronFeledy deleted the fix/nginx-worker-user branch February 20, 2026 00:49
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.

Wrong nginx user at running

1 participant