Apache web server treats two identical files differently - specifically all the images break on one of them

Quick description: I have a home network with a Linux box running an Apache server, and a Windows 10 box without a web server. both machines have similar directory structures for .html files and images, etc. When I display a page (any page) via the server it/they work fine. When I display identical pages on the Windows machine directly through its browser they work fine. But, when I display the Windows’ page through the web server (details below), all of the images break. There are no error messages in the console.

Some background: I usually create my html on the Windows machine, just using the local browser for verification, and then move it to my …/public_html directory when ready. But, I recently started dabbling in .php and that doesn’t work without a server. I have the Linux directory shared on the Windows machine, and have been working the php stuff directly from the Linux directory, but I really don’t like mucking up my “production” environment with development crap. That, and some other ideas I was working with got me to looking into alternative solutions. After reading the documentation for installing an Apache server on the Windows machine, I really didn’t want that kind of pain, so I came up with this idea, instead.

Details: I have shared the Windows html directory and mounted it on Linux as /var/www/html/windows*. (I have no idea if this is good practice, and am not really concerned, since this is all in-house, personal use.) It works. I can point to the .php files on the Windows directory, and they work just fine. However, none of the images display. There are no error messages in the console. I can “see” all of the image files in the Linux directory, and they have rwxr-xr-x permissions. I have no idea how to even begin a search on the techie websites, and am not inclined to do so anyway, since this is my own personal use, not work related, and I’m really more interested in what is (not) going on here, rather than being scolded for not using best practices.

  • for what it is worth, I chose to mount it under /var/www/html rather than …/public_html because the …/public_html is part of the directory shared to Windows, and I wasn’t sure how that kind of circular referencing would work (or not work.)

More background, in case you’re interested. I was an applications programmer for 25 years (mostly main-frame, but some Unix and Windows NT, with enough web development in the later years to know basic html and javascript to do my job. I was by no means a web developer. But I have been retired for 17 years, so most of that is old technology. Now, I keep myself entertained with my own suite of in-house (literally) applications, which I am constantly dickering with.

So I am throwing this out there for anyone who likes to solve problems. Thanks in advance for any light you can shed on this.

Is the Windows directory mounted as a Samba mount? If so you may need to disable the ‘sendfile’ support by setting

EnableSendfile Off

in your Apache configuration. (Sendfile uses a kernel feature to send the contents of a file over a network socket without Apache having to read the file. But it doesn’t work on Samba mounts.)

edit: you might also need

EnableMMAP off

This is probably too basic since it sounds like you are pretty knowledgeable, but Microsoft has no issues with letter case when it comes to linked images, whereas Linux does. So if the HMTL file calls for ‘imageone.jpg’ but the actual image is ‘imageOne.jpg’ the file will show up fine on a Windows box but will break in Linux.

  1. Check your browser’s developer tools to see exactly what paths are being requested and failing.

  2. Check the server’s access/error logs to see what requests the server is receiving and why it can’t serve them.

It may be that the paths in your HTML are absolute instead of relative, and that’s causing the failures with the files located in a folder instead of at the server root level.

@ctnguy got it in one! Woo Hoo! Neither of those settings were in the .conf. The Apache doco said the EnableSendFile default was Off, but just to be sure I added
<Directory /var/www/html/windows/>
EnableSendFile Off
EnableMMap Off
</Directory>
to the file and restarted the service. That fixed it.

I am almost embarrassed to admit that I had totally spaced on looking in the Apache error.log, but turns out it wouldn’t have made a difference, because there were no error entries. However, the access.log had a GET message for each of the files accessed, and the return code was 200 for all of them, so they were successfully retrieved, just mangled in the process.

This is the kind of arcane sh*t that makes me very happy I no longer do this for a living. I would be old and gray before I had stumbled on this solution on my own. Oh, wait…

I am old and gray. Ha!

Big Thank You to @ctnguy, and to the others who offered help.