Another grumpy sysadmin

[ Home | RSS 2.0 | ATOM 1.0 ]

Thu, 07 Jun 2018

Apache Icons

So, there I was, setting up the website, and I decided to add some icons to it to break up the text.

I tried setting up a symlink to make /icons on the webserver point to /usr/share/icons on my system, but that didn't work for some reason. I didn't want to waste too much time figuring out exactly what the problem was, so I tried adding an "Alias" directive for /icons to the Apache config, and that worked, so I moved on and decided to come back to the problem later.

The other night, I went back to it. I removed the "Alias" directive, leaving only the symlink in place, and tried to figure out what was happening. I kept getting HTTP 404 "Not Found" errors for the icons, and an HTTP 403 "Forbidden" error for the directory itself. Clearly, something was not right.

I checked that the symlink was correct - yes. I checked that the user that the webserver ran under had permissions to read the /usr/share/icons directory on the underlying filesystem - yes. I added a "Directory" directive for /usr/share/icons and ensured that the "Options" were set to follow symlinks, and to allow indexes (directory listings) - yes. Still not working.

So I checked everything again. Then I had a browse round StackExchange and its member sites for issues with symlinks or directory listings not working. Still nothing.

Eventually, I did what I probably should have done some time before, and checked the error log. There I found the significant clue: Cannot serve directory /usr/share/apache2/icons/.

It turns out that the default configuration of mod_autoindex, which is enabled by default in Apache installations on Debian, takes over the /icons URL to serve up the filetype icons in directory listings, from /usr/share/apache2/icons. Further, that directory is set to not serve directory listings, so no matter what options I put on the /usr/share/icons directory, it wasn't going to make any difference to the options for the directory that was actually being served up.

By moving my symlink from /icons to /img/icons, and updating all the links appropriately, suddenly everything worked again.

So, lesson learned - check the error log sooner next time.

But... it seems odd to me that a built-in Apache module would take over such an obvious and useful part of the root namespace on all websites for itself. Do the authors really think that no-one would want to use /icons on their own site? It's not just mod_autoindex, either. mod_info uses /server-info, mod_ldap uses /ldap-status, and mod_status uses /server-status. Granted, these locations aren't quite as valuable as /icons, and not all of those modules are enabled by default.

Still, I'd have thought that Apache would reserve something more obscure, like /x-apache/, or even /x-\*) and require all modules to use a subset of this namespace instead.

Maybe I should submit a patch...

posted at: 16:28 | path: / | permanent link to this entry

Made with Pyblosxom