Nginx 1.7.0: location @php

Francis Daly francis at daoine.org
Sat May 31 11:27:45 UTC 2014


On Sat, May 31, 2014 at 06:31:09AM -0400, TECK wrote:

Hi there,

>> Perhaps the request that you made did not match the location blocks that
>> you showed?

> If that would be the case, the proper code posted earlier would not work, so
> this is not the case.

That's a reasonable assumption to make, if I can reproduce your reported
problem.

When I use

  location ^~ /setup {
    try_files $uri $uri/ /setup/index.php?$uri&$args;
    location ~ \.php$ {
      try_files @php =404;
    }
  }

and I request /setup/real.php, I get back 404, not the unparsed content
of /usr/local/nginx/html/setup/real.php or anything else.

When I request /setup/fake.php, I get back 404.

When I request /other/real.php, I get back the unparsed content of
/usr/local/nginx/html/other/real.php.

Because I have shown you the config, the request, and the response, you
(and anyone else) can repeat the tests. If you get a different response,
then there is something extra involved that should be investigated before
the problem can be understood.

Perhaps different versions of nginx are involved. Perhaps different
modules are compiled in. Perhaps other configuration applies that was
not provided in the original example. After the reproducible test case
shows itself to be really reproducible, those differences possibly can
be ignored.

> I understand the try_files concept very well.

The older http://forum.nginx.org/read.php?2,217122 (and
replies) suggests that you didn't; and this thread (at
http://forum.nginx.org/read.php?2,250342 plus replies) suggests that
you don't.

> My original question was how to avoid repeating
> a segment of configuration code endless times,

No, it wasn't.

It may have been what you intended, but it wasn't what you asked.

http://forum.nginx.org/read.php?2,250342

> more exactly this:
> 	try_files $uri =404;
> 	fastcgi_split_path_info ^(.+\.php)(/.+)$;
> 	fastcgi_pass fastcgi;
> 	fastcgi_param PATH_INFO $fastcgi_path_info;
> 	fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
> 	include fastcgi.conf;
> 
> Using logic and the examples provided into Nginx documentation what I posted
> previously should work.

No, it shouldn't. http://nginx.org/r/try_files.

"file", "uri", and "=code" are different things. "..." means "optional
repetition of the previous" -- so there can be multiple "file" parameters,
and exactly one "uri" or exactly one "=code".

If there is a phrasing that would make the documentation clearer on that
point, I'm sure it would be welcomed. (But it seems clear to me already,
so I'm not sure what to change.)

> Can you provide a solution to my question?

http://nginx.org/r/include

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list