Welcome! Log In Create A New Profile

Advanced

Re: Understanding alias (used as rewrite)

E.B.
June 24, 2015 08:20PM
First big appreciated to you and Edho
for helping!! Especially for things not
documented . :)

> you seem to keep referring to "alias used as rewrite". I do not know
> what you mean by that.
>
> Could you explain?

Sure I wanted to take a prefix:

/my-long-base-path

and make sure all uris that match
that prefix are served to the same
file.

I got a rewrite to do that perfectly
but I see a lot of talk that rewrites
are what you used in apache and are
slow and not the nginx way of thinking.
and it make sense that because the
target file is fixed that avoiding
the rewrite engine will be faster just
pointing to a static aliased file.

I digress but hearing your opinion on
this is interesting to me.

> "alias" is, as you noted, documented at http://nginx.org/r/alias. It is
> used to identify a filename that should be used to handle the request.

Im still wondering why the critical part
you kindly explaining below is not documented.
Isn't this basic feature and important info
to know?

> In short: there are two relevant kinds of location: prefix and
> regex. ("exact" is a special case of "prefix".)
>
> In a prefix location, the starting part of the request that matches the
> "location" value is replaced with the "alias" value, and what results
> becomes $request_filename. (There is more to it than that, but that
> should be enough for now.)
>
> In a regex location, the entire request is replaced with the "alias"
> value, and what results becomes $request_filename.

thanks. might have been causing less trouble
to the mailing list if this was known from the
docs. :)

> In your example configs, if you replace the "include" line with something
> like
>
> return 200 "location #1: request $request_uri -> file $request_filename\n";

this was so helpful it is amazing! removing
all guessworkd! this should be included in
the docs too! i am very thankful to you for this!

> (change the #1 to something that will identify the location to you each
> time), then you can use "curl" to make your various requests and see
> the responses.
>
> Does that show you how each configuration was used?

i discovered in the fastcgi conf file there
was a:
try_files $uri =404

so it overrided the alias and causeding
the problem. i guess this was a security
measure to prevent sneaking around the
filesystem for php requests. is there a
better way to effect same protection?
try_files $request_filename =404????

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Understanding alias (used as rewrite)

E.B. June 22, 2015 06:06AM

Re: Understanding alias (used as rewrite)

Edho Arief June 22, 2015 02:22PM

Re: Understanding alias (used as rewrite)

E.B. June 22, 2015 04:34PM

Re: Understanding alias (used as rewrite)

Edho Arief June 22, 2015 11:20PM

Re: Understanding alias (used as rewrite)

E.B. June 24, 2015 02:46AM

Re: Understanding alias (used as rewrite)

Edho Arief June 24, 2015 06:52AM

Re: Understanding alias (used as rewrite)

Francis Daly June 24, 2015 11:44AM

Re: Understanding alias (used as rewrite)

E.B. June 24, 2015 08:08PM

Re: Understanding alias (used as rewrite)

E.B. June 24, 2015 08:20PM

Re: Understanding alias (used as rewrite)

Francis Daly June 25, 2015 01:54PM

Re: Understanding alias (used as rewrite)

E.B. June 27, 2015 03:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 137
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready