Drupal 9 files storage on Azure App service

Viewed 467

Been fighting with the problem for a month now. Have Drupal 9 set up on Azure App service with docker images running php8 (base image drupal:9.1.7-php8.0-apache) I have found out that there are two ways to have the "sites/default/files" public files directory served in azure:

  1. Symlink "sites/default/files" folder to "/home/files" folder and set WEBSITES_ENABLE_APP_SERVICE_STORAGE to true in application settings.
  2. Mount Azure file share directly on top of "sites/default/files" folder using Path mappings (currently in preview).

Both options works, my files are uploaded successfully and I can see them in the storages. Drupal also sees those files, BUT every time I try to access any of the uploaded files, I get 500 error with the only error being Failed to forward request to application. Encountered a System.Net.Http.HttpRequestException exception after 119.915ms with message: Received an invalid status line: 'anges: bytes'.. Check application logs to verify the application is properly handling HTTP traffic. If I delete the uploaded file, the app reacts and shows that file not found instead.

If I disable persistent storage (any of the options mentioned above), the files are uploaded correctly, no errors are shown, but the problem is that every time the app is restarted or deployed, the files are gone.

Drupal has no errors in its log. Apache logs have no more useful info (GET seems to be ok and returns 200). Have tried messing with apache.conf, with php.ini, with both .htaccess files allowing all kinds of nasty things, but still have no clue. Had multiple colleagues look into this and nothing seems to work.

2 Answers

Adding EnableSendfile On into Dictionary block resolved the problem.

Example:

<Directory /media/share/www/>
        EnableSendfile On
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride None
        Require all granted
</Directory>

Quick update: Tried every last thing I could imagine. Had numerous people try and help, but the same error 500 or 502 appears. Two weeks no answer from microsoft support.

Created new app service not with docker containers but php 7.4 and manually uploaded all drupal files to /home/site/wwwroot, also set WEBSITES_ENABLE_APP_SERVICE_STORAGE to true so that /home dir stays persistant and the web seems to be working just fine, files are all good.

In previous attempts and now azure ssh shows all files inside /home dir as nobody:nogroup 777, will investigate this further as this might lead to some security issues if this is true (but checked settings.php etc. files and they are protected atleast from web access)

Related