Welcome! Log In Create A New Profile

Advanced

Re: Understanding location blocks and try files

Jonathan Matthews
January 22, 2014 04:08PM
On 22 January 2014 20:36, Francis Daly <francis@daoine.org> wrote:
> On Wed, Jan 22, 2014 at 02:54:35PM -0500, AD7six wrote:
>
> Hi there,
>
>> location ~ \.php$ {
>> location ~* \.(?:manifest|appcache|html?|xml|json)$ {
>
>> A valid response where the url is a file:
>>
>> $ curl -i http://nginx.dev/foo.json
>> HTTP/1.1 200 OK
>
>> An invalid response when passed to php:
>>
>> $ curl -i http://nginx.dev/apples.json
>> HTTP/1.1 404 Not Found
>
> Why do you think that this request is passed to php?

I /believe/ AD is thinking along these lines:

* I have a server{} level "try_files", which goes $uri, $uri/, /index.php?$args;
* When file.json is present in the server{}-level root, it should be
served (and is) due to try_files trying the "$uri" setting first;
* When file.json is /missing/, the try_files setting should then
result in nginx falling back to the php location, which AD then
expects to do something meaningful with this request ...

.... and its this last step which isn't working as expected. I don't
quite have the explanation or docs to hand to say why this won't work,
but this SO page seems to have an interestingly un-up-voted answer at
the bottom of the page:
http://stackoverflow.com/questions/13138318/nginx-try-files-outside-location

"You are probably under the delusion that try_files on server level
must work for every request. Not at all. Quite the contrary, it works
only for requests that match no location blocks."

I'd be really interested to get confirmation that that statement is
unequivocally true!

Jonathan

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

Understanding location blocks and try files

AD7six January 22, 2014 01:31PM

Re: Understanding location blocks and try files

Jonathan Matthews January 22, 2014 02:04PM

Re: Understanding location blocks and try files

AD7six January 22, 2014 02:54PM

Re: Understanding location blocks and try files

Francis Daly January 22, 2014 03:38PM

Re: Understanding location blocks and try files

Jonathan Matthews January 22, 2014 04:08PM

Re: Understanding location blocks and try files

Valentin V. Bartenev January 22, 2014 04:32PM

Re: Understanding location blocks and try files

Francis Daly January 22, 2014 05:20PM

Re: Understanding location blocks and try files

AD7six January 23, 2014 06:54AM

Re: Understanding location blocks and try files

Francis Daly January 23, 2014 08:44PM

Re: Understanding location blocks and try files

AD7six January 24, 2014 11:17AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 156
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