Alias routing in nginx-0.8.13

Hi all,

I just upgraded to nginx-0.8.13 and found that there is a change in
alias routing, making part of my website does not work any more.

My configuration

    location ~ /gostats($|/.*) {
       autoindex on;
       access_log off;
       alias /home/web/usage/site$1;
       index index.html;

       # if the requested file exists, return it immediately
       if (-f $request_filename) {
           break;
       }
    }

It works in 0.8.9, 0.8.10 but not in 0.8.13

Here is the error log when I access to http://mydomain.com/gostats

2009/09/02 13:21:25 6481#0: *77052 open()
“/home/web/usage/site/index.htmlhtml” failed (2: No such file or
directory), client: 117.1.253.209, server: mydomain.com, request: “GET
/gostats/ HTTP/1.1”, host: “mydomain.com

The problem is there is redundant “html” appended to the static HTML
file, making /home/web/usage/site/index.html into
/home/web/usage/site/index.htmlhtml

Is is a bug?

Posted at Nginx Forum:

On Wed, Sep 02, 2009 at 02:24:57AM -0400, pcdinh wrote:

       index index.html;

2009/09/02 13:21:25 6481#0: *77052 open() “/home/web/usage/site/index.htmlhtml” failed (2: No such file or directory), client: 117.1.253.209, server: mydomain.com, request: “GET /gostats/ HTTP/1.1”, host: “mydomain.com

The problem is there is redundant “html” appended to the static HTML file, making /home/web/usage/site/index.html into /home/web/usage/site/index.htmlhtml

Is is a bug?

Yes. This is because of

if (-f $request_filename) {
    break;
}

You do not need this.

Also, you may use just without any regex:

     location /gostats {
        autoindex on;
        access_log off;
        alias /home/web/usage/site;
        index index.html;
     }

I did as you told but it did not work. Here is my configuration

   location /gostats {
       autoindex on;
       access_log off;
       alias /home/web/usage/site;
       index index.html;
    }

    location ~ /go2stats($|/.*) {
       autoindex on;
       access_log off;
       alias /home/web/munin$1;
    }

While requests to /go2stats work perfectly, requests to /gostats
generate error logs that indicate Nginx tried to find
“/home/web/usage/site/index.htmlhtml” instead of
“/home/web/usage/site/index.html”

Do you think that a bug occurs when someone configures 2 location with
alias enabled?

Thanks

Igor S. wrote:

Is is a bug?

Yes. This is because of

if (-f $request_filename) {
    break;
}

You do not need this.

Also, you may use just without any regex:

     location /gostats {
        autoindex on;
        access_log off;
        alias /home/web/usage/site;
        index index.html;
     }