$host doesn't work with case insensitive domains

Hi

for example,

domain.com will work fine.
but if I will request Domain.com/DOMAIN.COM/domAin.com
it will result in a Not Found 404 (because there is no
“/var/www/html/domAin.com” etc.)

I used the $host variable for virtual hosts
root /var/www/html/$host;

it happens because the directory is in lowercase name in linux
(/var/www/html/domain.com)
so is there anyway to make nginx read all incoming domains as lowercase
ones ?

p.s sorry for the bad english.

thanks.

Posted at Nginx Forum:

Why don’t you use Embedded Perl (
http://wiki.nginx.org/NginxEmbeddedPerlModule ) to do a string to
lower type function , so the path is sanitized?

David M.

Thats a good idea, but I dont know how.

Marcos N.
+55 44 9918-8488

On Wed, Sep 23, 2009 at 12:50:07AM -0400, ami wrote:

it happens because the directory is in lowercase name in linux (/var/www/html/domain.com)
so is there anyway to make nginx read all incoming domains as lowercase ones ?

The attached patch fixes the bug. It’s suitable for 0.8 and 0.7.

On Wed, Sep 23, 2009 at 10:03 PM, David M. [email protected]
wrote:

Why don’t you use  Embedded Perl ( http://wiki.nginx.org/NginxEmbeddedPerlModule ) to   do a string to lower type function , so the path is sanitized?

David M.

IMO, considering domain name is case insensitive, it should be done
internally.

On Wed, Sep 23, 2009 at 01:59:47PM -0400, ami wrote:

also with 0.7 there is no success.

Posted at Nginx Forum: Re: $host doesn't work with case insensitive domains

It seems you did copy/paste from forum message. For some reason the
patch
was not placed as separate file with forum message. Try this:
http://sysoev.ru/nginx/patch.host.lowcase

Thanks Igor!

but there seems to be a problem with the patch ?

patch -p0 < nginx.patch

patching file src/http/ngx_http_request.c
patch: **** malformed patch at line 6: static ngx_int_t
ngx_http_process_request_header(ngx_http_request_t *r);

also with 0.7 there is no success.

Posted at Nginx Forum:

you are right,

Works like a charm!

thanks :slight_smile:

Posted at Nginx Forum: