Skip to content

Commit cc7b549

Browse files
committed
fix: patch Bitnami nginx-env.sh to use www-data worker user
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
1 parent 051689a commit cc7b549

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

config/launch.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ fi
4747
lando_info "Rendered template /tmp/vhosts.lando to /opt/bitnami/nginx/conf/vhosts/lando.conf"
4848
lando_debug $(cat /opt/bitnami/nginx/conf/vhosts/lando.conf)
4949

50+
# Set nginx worker user to www-data so it can serve files created by PHP
51+
# Bitnami's nginx-env.sh hardcodes NGINX_DAEMON_USER=daemon which overwrites
52+
# any env var we set, so we patch it before the entrypoint runs
53+
# See: https://github.com/lando/drupal/issues/124
54+
if [ -f "/opt/bitnami/scripts/nginx-env.sh" ]; then
55+
sed -i 's/export NGINX_DAEMON_USER="daemon"/export NGINX_DAEMON_USER="www-data"/' /opt/bitnami/scripts/nginx-env.sh
56+
sed -i 's/export NGINX_DAEMON_GROUP="daemon"/export NGINX_DAEMON_GROUP="www-data"/' /opt/bitnami/scripts/nginx-env.sh
57+
fi
58+
5059
# Detect and run the correct entrypoint script. THANKS BITNAMI!
5160
if [ -f "/opt/bitnami/scripts/nginx/entrypoint.sh" ]; then
5261
/opt/bitnami/scripts/nginx/entrypoint.sh /opt/bitnami/scripts/nginx/run.sh

config/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
2-
user www-data www-data; ## Default: nobody
2+
user root root; ## Default: nobody
33

44
worker_processes auto;
55
error_log "/opt/bitnami/nginx/logs/error.log";

0 commit comments

Comments
 (0)