Apache 正在向图像添加 header,导致图像损坏

Apache is adding header to images resulting in corrupting images

我正在对一个 laravel 应用程序进行 docker 化,我的图像基于 apache 图像,它托管在 AKS 中,我在其中安装带有图像共享的 azure 文件 /public/images,问题是 apache 会在图像中添加 header,导致图像损坏

即使我在 pod 本身内部执行并尝试 curl 本地主机,我也会遇到同样的问题,所以我确定这不是路由或入口的问题

    FROM php:7.3-apache

#install all the system dependencies and enable PHP modules 
RUN apt-get update -y && apt-get install -y libmcrypt-dev openssl
RUN apt-get update && apt-get install -y libmcrypt-dev \
    && pecl install mcrypt-1.0.2 \
    && docker-php-ext-enable mcrypt
RUN docker-php-ext-install pdo mbstring 
RUN apt-get install -y \
        libzip-dev \
        zip \
  && docker-php-ext-install zip
RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-install mysqli pdo pdo_mysql
# RUN apt-get install wget
RUN apt-get update; apt-get install curl -y

#install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer

#set our application folder as an environment variable
ENV APP_HOME /var/www/html

#change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data

#change the web_root to laravel /var/www/html/public folder
#RUN sed -i -e "s/html/html\/public/g" /etc/apache2/sites-enabled/000-default.conf
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
RUN echo "EnableSendfile off" >> /etc/apache2/apache2.conf


# enable apache module rewrite
RUN a2enmod rewrite

#copy source files and run composer
COPY . $APP_HOME

# install all PHP dependencies
RUN composer install --no-interaction


#change ownership of our applications
RUN chown -R www-data:www-data $APP_HOME

接下来使用常规部署 yaml 文件将其推送到具有以下卷装载的 kubernetes:

volumeMounts:
- name: sessions
  mountPath: /var/www/html/storage/framework/sessions
- name: cache
  mountPath: /var/www/html/storage/framework/cache
- name: views
  mountPath: /var/www/html/storage/framework/views
- name: images
  mountPath: /var/www/html/public/images

数量:

现在的问题是,如果我尝试从图像文件夹访问静态文件,例如使用 url,例如“https://www.somedomain.com/images/somefile.png”

文件将被下载,但 apache 会将上述 headers 附加到导致损坏的内容。

Web 应用程序运行良好,除了卷装载内的任何文件。

如果我执行“kubectl exec -it podname -- bash”并浏览文件,我可以看到卷安装工作正常,如果我尝试从应用程序界面上传文件,文件文件夹里面的写入方式,唯一的问题是浏览文件。

我们解决了这个问题,只是在 vhost.conf,我们需要关闭 EnableMMAP

EnableMMAP off