Context
I am using Azure File Share to sync my media files in the app service every time a container starts. The reason I am using File Share and not Blob storage is because there is no write access (only read access) provided by Azure for Blob storage feature, more info on that here. Moreover the file sync works fine with the File Share storage i.e. I can see the files that were uploaded into the Azure File Share inside my container mount path which is: /var/www/html/<app-name>/web/sites/default/files
and the Drupal 9.2.4 application that the container is running can also write to the same mount path and I can see the newly created files on the File Share as well.
Issue
The issue is all the images/PDFs files inside the above mount path show a 502 Bad Gateway
on the browser, however the CSS files that the Drupal application loads inside the same mount path work fine. The web application works fine, the issue is ONLY with the images being loaded in the above mount path.
Link to the web application: rtastaged9.azurewebsites.net
The site is not using a SSL.
Things that I have already tried and do not work:
- Changed the tier of File Share from 'Hot' to 'Performance Optimized'.
- Scaled up the app service plan to use P2V3 (16 GB memory) from P1V3 (8 GB memory).
- Set the FQDN (Servername) of the apache2 in the container to be: rtastaged9.azurewebsites.net
- The Log stream in the app service shows
200 OK
for the same images/PDFs that are showing 502 Bad Gateway
on the browser.
- The
default_docker.log
under /LogFiles/
of app service also shows images/PDFs 200 OK
.
- The Drupal's
/admin/reports/dblog
shows no sign of any 502 Bad Gateway
errors.
- Tried clearing cache with
drush cr
command.
Moreover if the container is not connected to the storage account, the images/PDFs in the above mount path work fine but of-course the files would not persist that way in the container.
Also just in case below is my Dockerfile that I am using to build the Drupal container and pushing it to Azure Container Registry
and from there I am using the app service to use the image plus an Azure MySQL instance is connected to the same app service. Let me know if you want me to provide any more info, would appreciate any help.
FROM osiolabs/drupaldevwithdocker-php:7.4
ENV APACHE_DOCROOT_DIR=/var/www/html/<app-name>/web/
#Set the Server name
ENV APACHE_SITE_NAME=rtastaged9.azurewebsites.net
#Set the Server alias
ENV APACHE_SITE_ALIAS=rtastaged9.azurewebsites.net
COPY /<app-name> /var/www/html/<app-name>
RUN composer self-update --2
WORKDIR /var/www/html/RTA-D8
RUN composer install
WORKDIR ../../../../
# ssh for azure app service
ENV SSH_PASSWD "root:Docker!"
RUN apt-get update \
&& apt-get install -y --no-install-recommends dialog \
&& apt-get update \
&& apt-get install -y --no-install-recommends openssh-server \
&& echo "$SSH_PASSWD" | chpasswd
RUN mkdir /run/sshd
COPY sshd_config /etc/ssh/
EXPOSE 80 443 2222
CMD /usr/sbin/sshd && apachectl -D FOREGROUND