Skip to content
New issue

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

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

Already on GitHub? # to your account

nginx-drupal: unable to run update.php from the browser (workaround included) #743

Open
AlexSkrypnyk opened this issue May 7, 2023 · 0 comments

Comments

@AlexSkrypnyk
Copy link

AlexSkrypnyk commented May 7, 2023

Using nginx-drupal image, it is not possible to run update.php in the browser as it is not allowed in the nginx configuration. Whether it was done on purpose to enforce CLI-only updates, or represents a config defect - there are cases where update.php should run (specifically - writing tests for hook_update_N() that require update.php to be accessible from the browser).

After some time trying different methods of overriding location and looking into how update.php can be used as update.php/info, update.php/section etc., the working solution includes:

  1. Creating location_prepend_update_php.conf with content:
location ~ ^/update.php {
    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
    include        /etc/nginx/fastcgi.conf;
    fastcgi_pass   php:9000;
}
  1. Copying it into /etc/nginx/conf.d/drupal/ so the resulting file has a path of /etc/nginx/conf.d/drupal/location_prepend_update_php.conf

The above would work, however it does not re-use @php location block from the drupal.conf because using:

location /update.php {
  try_files /dev/null @php;
}

would not pass fastcgi_split_path_info ^(.+?\.php)(|/.*)$; to the @php block.

I'm not sure about the best approach to extending @php block with fastcgi_split_path_info ^(.+?\.php)(|/.*)$; as it may have security implications.

I'm looking for a comment from the Lagoon team on this - is it a defect in the config and it should be fixed or if this is an intended "lock", in which case I'm wondering about the best approach to allow this on per-site basis while reusing @php block.

@AlexSkrypnyk AlexSkrypnyk changed the title Unable to run update.php from the browser (workaround included) nginx-drupal: unable to run update.php from the browser (workaround included) May 7, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant