4

I'm using nginx with PHP-FPM

My application requires all urls to be redirected to index.php (see nginx conf)

location / {
    root /var/www/app/public/
    try_files $uri /index.php?$args;
}


location ~ \.php$ {         
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    try_files $fastcgi_script_name =404;

    set $path_info $fastcgi_path_info;
    fastcgi_param PATH_INFO $path_info;

    fastcgi_index index.php;

    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

To analyze some performance issues I wanted to use the fpm status page. But the status page doesn't show me the real request URI

pid:                  1369
state:                Idle
start time:           03/Sep/2018:17:34:34 +0200
start since:          15
requests:             4
request duration:     29796
request method:       GET
request URI:          /index.php
content length:       0
user:                 -
script:               /var/www/app/public/index.php
last request cpu:     67.12
last request memory:  6291456

So it's hard to tell which page is currently processed - is it maybe possible to add some additional info to fpm-status page or change the request URI?

2
  • Why have you removed the default line include fastcgi_params;? Put it back first. Sep 3, 2018 at 16:55
  • I changed location so it only uses include fastcgi_params and fastcgi_pass but result is the same
    – RCX
    Sep 3, 2018 at 17:27

4 Answers 4

2

This worked for me:

 location ~ ^/index\.php(/|$) {
     fastcgi_pass 127.0.0.1:9000;
     fastcgi_split_path_info ^(.+\.php)(/.*)$;
     include fastcgi_params;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_param SERVER_NAME $http_host;
     fastcgi_param SCRIPT_NAME $request_uri;
 }

Ref: https://jolicode.com/blog/how-to-see-full-request-uri-in-fpm-status

1

Still no answer, a bug was opened over 5 years ago on https://bugs.php.net/bug.php?id=72319 with no reply.

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Nov 30, 2021 at 18:13
0

You have to add a block its own block with a fastcgi_index set:

location ~ ^/_status$ {     
    include fastcgi_params
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_index index.php;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

    # the following is optional but nice to have
    # it will restrict access to the local monitoring system
    access_log off;
    allow 127.0.0.1;
    allow ::1;
    deny all;

}
0

For my problem solution was:

        fastcgi_param  PATH_INFO  $request_uri;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .