Forum: NGINX Alias not working on 0.7.35

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Glen L. (Guest)
on 2009-03-31 11:02
(Received via mailing list)
I tried to put this configuration on my nginx.conf



    location  /default/ {

        alias  /home/myhome/content/;

    }



        location ~ \.flv$ {

            flv;

        }



But it doesn't work.



When opening a FLV files, it always pointed me to the root directory
which
is /home/myhome



Is there anythink i've missed?
Igor S. (Guest)
on 2009-03-31 11:14
(Received via mailing list)
On Tue, Mar 31, 2009 at 01:56:01PM +0700, Glen L. wrote:

> But it doesn't work.
>
> When opening a FLV files, it always pointed me to the root directory which
> is /home/myhome
>
> Is there anythink i've missed?

You need the last 0.7.x:

     location    /default/ {
         alias  /home/myhome/content/;
     }

     location ~ ^/default/(.+\.flv)$ {
         alias  /home/myhome/content/$1;
         flv;
     }
Glen L. (Guest)
on 2009-04-01 07:05
(Received via mailing list)
2009/3/31 Igor S. <removed_email_address@domain.invalid>

> >         }
>
>     location    /default/ {
>         alias  /home/myhome/content/;
>     }
>
>      location ~ ^/default/(.+\.flv)$ {
>         alias  /home/myhome/content/$1;
>         flv;
>     }

Why do we need to put an alias on the flv?
Is this method not work on 0.6.35 ?

>
Igor S. (Guest)
on 2009-04-01 09:15
(Received via mailing list)
On Wed, Apr 01, 2009 at 09:59:39AM +0700, Glen L. wrote:

> > >         location ~ \.flv$ {
> >
>
> Why do we need to put an alias on the flv?

Because "/default/some.flv" will choose "\.flv$" location, but not
"/default/" one.

> Is this method not work on 0.6.35 ?

No, currently 0.6.x does support captures in location, and I'm not sure
if I will merged it from 0.7: there are many changes in location
processing
in 0.7.
Glen L. (Guest)
on 2009-04-03 07:01
(Received via mailing list)
Here's my configuration

        root    /home/myhome;

        access_log  /var/log/nginx/access.log;

        location ~ \.flv$ {
            flv;
        }

        location    /default {
            alias  /home/yourhome/content;
        }

        location ~ ^/default/(.+\.flv)$ {
            alias  /home/yourhome/content/$1;
            flv;
        }

When I tried to access /default/filename.flv, it still redirect me to
/home/myhome/default/filename.flv. And it shows file not found

# nginx -v
nginx version: nginx/0.7.46
Igor S. (Guest)
on 2009-04-03 08:55
(Received via mailing list)
On Fri, Apr 03, 2009 at 09:51:39AM +0700, Glen L. wrote:

>         location    /default {
>             alias  /home/yourhome/content;
>         }
>
>         location ~ ^/default/(.+\.flv)$ {
>             alias  /home/yourhome/content/$1;
>             flv;
>         }
>
> When I tried to access /default/filename.flv, it still redirect me to
> /home/myhome/default/filename.flv. And it shows file not found

You need to change order of regex locations:

         location ~ ^/default/(.+\.flv)$ {
             alias  /home/yourhome/content/$1;
             flv;
         }

         location ~ \.flv$ {
             flv;
         }

Otherwise, "\.flv$" is matched first.
Glen L. (Guest)
on 2009-04-03 10:06
(Received via mailing list)
Thank's Igor. It's works now!

When it will be implemented into the stable version?
This topic is locked and can not be replied to.