Welcome! Log In Create A New Profile

Advanced

nginx + php-fpm: REQUEST_URI disappears for files that end with .php

Posted by ST 
Hello,

I have following nginx + php-fpm configuration but for some reasons
files that end with .php miss REQUEST_URI when they arrive to php-fpm.

For instance:

https://n.example.com/audio/radio/ -> array(1)
{ ["REQUEST_URI"]=> string(15) "/audio/radio/" }
https://n.example.com/rus_example.html -> array(1)
{ ["REQUEST_URI"]=> string(15) "rus_example.html" }
https://n.example.com/rus_example.php -> array(0) { }


What is wrong?
Thank you!

Here is my configuration:

location / {
try_files $uri $uri/ @netcat-rewrite;
}

location @netcat-rewrite {
rewrite ^/(.*)$ /netcat/require/e404.php?REQUEST_URI=$1 last;
}

error_page 404 = /netcat/require/e404.php;

location ~ \.php$ {
if ($args ~ "netcat_files/") {
expires 7d;
add_header Cache-Control "public";
}

fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root
$fastcgi_script_name;
fastcgi_param DOCUMENT_URI $document_uri;
include fastcgi_params;
}


PHP-FPM log:

no .php file:

08/Мар/2018:13:44:13 +0200
"GET /netcat/require/e404.php?REQUEST_URI=audio/radio/" 200

.php file:

08/Мар/2018:13:44:14 +0200 "GET /netcat/require/e404.php" 404

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Thu, Mar 08, 2018 at 01:48:41PM +0200, ST wrote:

Hi there,

* What request do you make? (e.g. /rus_example.php)
* Does the matching file exist on the filesystem
(e.g. /usr/local/nginx/html/rus_example.php)?
* If yes - what response do you want, and what response do you get?
* If no - what response do you want, and what response do you get?

> error_page 404 = /netcat/require/e404.php;
>
> location ~ \.php$ {
> if ($args ~ "netcat_files/") {
> expires 7d;
> add_header Cache-Control "public";
> }
>
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> try_files $uri =404;

If /usr/local/nginx/html/rus_example.php does not exist, that line
says "return 404", which the error_page line turns into a request for
/netcat/require/e404.php

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Hi Francis,

you are correct. You explained exactly what happens - thank you!


On Fri, 2018-03-09 at 00:01 +0000, Francis Daly wrote:
> On Thu, Mar 08, 2018 at 01:48:41PM +0200, ST wrote:
>
> Hi there,
>
> * What request do you make? (e.g. /rus_example.php)
> * Does the matching file exist on the filesystem
> (e.g. /usr/local/nginx/html/rus_example.php)?
> * If yes - what response do you want, and what response do you get?
> * If no - what response do you want, and what response do you get?
>
> > error_page 404 = /netcat/require/e404.php;
> >
> > location ~ \.php$ {
> > if ($args ~ "netcat_files/") {
> > expires 7d;
> > add_header Cache-Control "public";
> > }
> >
> > fastcgi_split_path_info ^(.+\.php)(/.+)$;
> > try_files $uri =404;
>
> If /usr/local/nginx/html/rus_example.php does not exist, that line
> says "return 404", which the error_page line turns into a request for
> /netcat/require/e404.php
>
> f

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login