Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong nginx user at running #124

Open
jffranck opened this issue Aug 13, 2024 · 3 comments
Open

Wrong nginx user at running #124

jffranck opened this issue Aug 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@jffranck
Copy link

Hi,
It seems that when using nginx in via config, the user of nginx server is "daemon" instead of "www-data".
As a consequency, when using the correct permissions on Drupal folders, all css and js files are returning a 403 error from nginx.
The only way to fix it that I found is to add this in services config:

  appserver_nginx:
    build_as_root:
      - sed -i "s/daemon/www-data/" /opt/bitnami/scripts/nginx-env.sh

Even adding a custom server.conf with config/config/server didn't work.

@jffranck jffranck added the bug Something isn't working label Aug 13, 2024
@reynoldsalec
Copy link
Member

@jffranck can you paste your entire Landofile? Curious if you're specifying an nginx version or making any other changes.

@jffranck
Copy link
Author

jffranck commented Aug 19, 2024

Hi @reynoldsalec,
Of course, here is my landofile:

name: project
recipe: drupal10
config:
  php: '8.3'
  via: nginx:1.24
  webroot: web
  database: mysql:8.0
  drush: true
  xdebug: true
  config:
    vhosts: docker/app/nginx/default.conf
    php: docker/app/php/php.ini
proxy:
  appserver_nginx:
    - local.project.com
    - project.lndo.site
services:
  solr:
    type: solr:8
    core: project
    forwardedport: true
    config:
      dir: docker/solr/config
  phpmyadmin:
    type: phpmyadmin
  nodejs:
    type: node:20
  appserver:
    build_as_root:
      - apt-get update -y
      - export DEBIAN_FRONTEND=noninteractive
      - apt-get install cron -yq
      - ln -snf /usr/share/zoneinfo/Europe/Paris /etc/localtime
      - echo "Europe/Paris" > /etc/timezone
      - echo "$CRON_FREQUENCY root drush cron -y" >> /etc/cron.d/project
      - mkdir -p /scripts
      - ln -s /app/docker/app/scripts/cron.sh /scripts/900-cron
  appserver_nginx:
    build_as_root:
      - sed -i "s/daemon/www-data/" /opt/bitnami/scripts/nginx-env.sh
tooling:
  npm:
    description: Run npm command in the project_b5 theme
    service: nodejs
    dir: /app/web/themes/custom/project_b5
  dfp:
    description: Run the drupal_fix_permissions script
    service: appserver
    cmd: /app/vendor/metadrop/drupal-fix-permissions/drupal_fix_permissions.sh -u=www-data -g=www-data -p=/app/web
    user: root

@angarsky
Copy link

angarsky commented Nov 17, 2024

@jffranck is right: something were broken in the configuration of NGINX container or the Drupal recipe. I had a stable local Lando environment for one of my Drupal projects. I didn't touch this project (and even any Drupal project locally) for a couple of months: I guess the most recent Lando build for a Drupal I did in the beginning of summer or even earlier.

Today I've done a rebuild of the project and got 403 error for JS/CSS assets.

Lando configuration (Docker Desktop 4.35.1, macOS Sonoma 14.5):

name: edume
recipe: drupal10
config:
  php: '8.2'
  via: nginx:1.18
  webroot: drupal/web
  database: mariadb:10.6
  drush: ^11
  xdebug: true
  config:
    php: .lando/php.ini

services:
  database:
    creds:
      user: admin
      password: admin
      database: drupal
  appserver:
    overrides:
      environment:
        PHP_MEMORY_LIMIT: "128M"

I've tried the most recent nginx:1.27 - it doesn't fix the issue.

Research

I connected to a container via lando ssh -u root appserver and executed next commands:

root@6e4e40521eb9:/app/drupal/web# ls -la core/modules/system/css/components/align.module.css
-rw------- 1 www-data dialout 484 May  1  2024 core/modules/system/css/components/align.module.css
root@6e4e40521eb9:/app/drupal/web# chown daemon core/modules/system/css/components/align.module.css  
root@6e4e40521eb9:/app/drupal/web# ls -la core/modules/system/css/components/align.module.css
-rw------- 1 daemon dialout 484 May  1  2024 core/modules/system/css/components/align.module.css

After that I was able to access the CSS file (w/o 403 error) in a browser by next URL: https://edume.lndo.site/core/modules/system/css/components/align.module.css. Thus yes, the issue is somewhere in nginx configuration that's related to daemon, www-data users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants