teaching machines

Apache and Icons

April 16, 2020 by . Filed under failures, public.

This semester I’m teaching a web development course. This is the first time I’ve taught the course, which means I have no Catalog of Errors that we teachers consult when trouble arises. Rather, I am writing the first entries in this Catalog as we speak.

This week I spent an hour chasing down a pernicious error with a student. The student’s website included some social media icons in the footer with the following HTML:

<img src="icons/facebookicon.png" alt="facebook icon">
<img src="icons/instagramicon.png" alt="instagram icon">
<img src="icons/twittericon.png" alt="twitter icon">
<img src="icons/youtubeicon.png" alt="youtube icon">

When viewed on the local machine, the images showed up fine. But when the site was deployed to the student’s Digital Ocean droplet and served out with Apache, the images showed up broken. Trying to directly access the images through https://domain/icons/youtubeicon.png yielded a 404. We fiddled with permissions, we checked paths, we hosted the site in other locations, and we despaired.

Finally I did searched the web in desperation for “Apache and icons.” Much to my surprise, I discovered that Apache on Ubuntu has a mod that messes with the /icons path. The file /etc/apache2/mods-enabled/alias.conf contains this line:

Alias /icons/ "/usr/share/apache2/icons/"

Any URL whose path component starts with /icons will get redirected to a different directory on the system. Argh. The mod is enabled by default so that the directory listings that Apache sometime serves can use icons.

The student fixed the issue by renaming the directory.

This one’s going in the Catalog.