Apache在ubuntu 18.04上安装了带有已安装映像目录的带有工件的映像 [英] Apache delivers images with artifacts on ubuntu 18.04 with mounted image directory
问题描述
我对通过apache2.4传递到Web浏览器的图片中的伪像有一个奇怪的问题.我们的comany使用中央图片存储存储所有产品图片.该目录安装在mnt/medamazonbild下的Web服务器中.我创建了一个符号链接,该链接指向img/artikel下的Web目录.这可以正常工作,并且该文件夹可以完全访问.
I have a strange issue with artifacts in pictures delivered via apache2.4 to the web browser. Our comany uses a central picture storage for all the product images. This directory is mounted into the webserver under mnt/medamazonbild. I created a symbolic link, which points into the web directory under img/artikel. This worked and the folder is fully accessible.
但是,一旦我通过chrome或firefox在目录下请求图片:
But as soon as I request a picture from the directory via chrome or firefox under:
172.17.1.27/img/artikel/70399.jpg
172.17.1.27/img/artikel/70399.jpg
输出附带工件.
出于测试目的,我尝试通过image.php中的PHP提供图像:
For test purposes I tried to deliver the image via PHP in image.php:
if (isset($_GET["img"])) {
// get image name
$img = filter_var($_GET["img"], FILTER_SANITIZE_STRING);
// path of image with name and suffix
$path = '/var/www/html/public/img/artikel/' . $img;
header('Content-Type: image/jpeg');
readfile($path);
}
结果是图像没有应有的伪像:
The result is the image without artifacts as it should be:
我不想用php处理所有图像的图像输出,因为我担心性能会下降. 如何获得针对Apache的解决方案,以按预期方式交付图像?错误在哪里?
I don't want to process the image output for all the images with php, because I'm afraid of performance decreases. How can I get a solution for apache to deliver the images as expected? Where is the error?
设置:
- Ubuntu 18.04 LTS
- Apache 2.4
- 安装目录,其图片位于:mnt/medamazonbild
- 从mnt/medamazonbild到webroot img/artikel的符号链接
推荐答案
我的图像上出现了相同类型的故障.
我使用的是官方docker image php:7.3-apache Docker Hub
为了解决这个问题,我在EnableSendfile on
(我认为它的作用与您将其添加到httpd.conf中的作用相同)
I have the same type of glitchs on my images.
I'm using the official docker image php:7.3-apache Docker Hub
To fix this issue I added EnableSendfile on
to my .htaccess (I think it works the same as if you add it in your httpd.conf)
这篇关于Apache在ubuntu 18.04上安装了带有已安装映像目录的带有工件的映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!