Welcome! Log In Create A New Profile

Advanced

Serve files case-insensitive on Linux

Posted by daniel_summers 
Serve files case-insensitive on Linux
May 06, 2010 12:17AM
Hello.

Let me start by saying that nginx is absolutely outstanding. It will soon be the only web server I run. :)

My dilemma is this. I know that Linux file systems (ext3, in this case) are case-sensitive. I've helped a client migrate from a shared Apache environment to an nginx environment on a CentOS 5.4 VPS, then on to a bigger Ubuntu 10.04 VPS when the first one proved to be too small. For both VPSs, I installed nginx from the provided repositories. These folks, being moderately technically savvy but not geeks like me, have a mix of case in certain filenames (images, etc.) Under Apache and the CentOS VPS, these files were served just fine, even though the case did not match the request. In the Ubuntu VPS, these are now returning 404's.

Were it one of my sites, I would just make the case match and be done with it; however, there's a large volume of data, plus there's no guarantee that they wouldn't attach file "Big-Tree.jpg" but link it as "big-tree.jpg" in the entry. Is there a way to make nginx use a case-insensitive search for files to serve? I looked through all the docs I could find, but couldn't find anything, and Google mostly returned regexes used for the location parameter of the config files.

Thanks!
Re: Serve files case-insensitive on Linux
May 10, 2010 05:30PM
I too am trying to figure out how to do this, anyone know how to do this?
Re: Serve files case-insensitive on Linux
June 07, 2010 03:13PM
Bump...
Re: Serve files case-insensitive on Linux
August 02, 2010 11:25AM
Bump again. Anyone?
Re: Serve files case-insensitive on Linux
August 02, 2010 12:36PM
Perhaps something like this might work

location ~* ^/(.*)$ {
... config ...
}

location ~* ^/some-other-location/(.*)$ {
... config ...
}
Re: Serve files case-insensitive on Linux
August 02, 2010 12:48PM
Thanks for the idea. I think the issue though is that the filesystem actually handles case sensitivity. I know I could get nginx to not care what a request is in so far as telling it what location{} to use, but ultimately it would still be requesting a file from the filesystem with a specific case sensitivity. I'm looking for ways around that.

Someone on IRC suggest just remounting the relevant parts of the filesystem using ciopfs: http://www.brain-dump.org/projects/ciopfs/. The issue there being that it doesn't take into account any requests that end up getting sent to a webapp, such as tomcat, and are either stored in a database or dynamically generated. Still, it may be the best we're going to get. This is done somehow in Apache using mod_spelling I believe: http://httpd.apache.org/docs/2.2/mod/mod_speling.html.
Re: Serve files case-insensitive on Linux
August 02, 2010 01:56PM
You're right ... it wouldn't work.

Perhaps write a script to recursively go through the directories and reset every .jpg file to lowercase and tell them to stick to lowercase.

Not the perfect and fool proof transparent solution but perhaps they need to take some responsibility once you fix the initial issue.

You'll be surprised how well people can adjust to such.
Re: Serve files case-insensitive on Linux
August 02, 2010 07:42PM
Thanks for the discussion. I know there's got to be some way, and the ciopfs looks interesting. My client's problem was a pretty well-established Google presence, and lots of 404's in the logs show that people are still trying to access them.
Re: Serve files case-insensitive on Linux
August 02, 2010 07:50PM
For what its worth Daniel, I have been asking around on IRC, my understanding is that currently nginx simply does not have the ability to ignore case. That leaves us with looking for ways around that with things like ciopfs... Please let me know if you happen to dig up another solution.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 56
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready