skip to Main Content

i am not able to get the php-fpm “/status|ping” -page to work.

a few specs:
OS Debian 6.0.10
Plesk version 12.0.18 Update #35, last updated at Feb 13, 2015 08:37 PM
PHP version is 5.4.37 (got it from dotdeb)

installed NGINX and PHP-FPM via upgrade feature thingy on PLESK 12

REMARK: example.com = my-real-hidden-domain-name.com

* configs and files *

*** section WEB SERVER SETTINGS
activated nginx settings
checkmark: Smart static files processing
NO checkmark: Serve static files directly by nginx
checkmark: Process PHP by nginx

*** Additional nginx directives

location ~ ^/(status|ping)$ {
    allow all;
    fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
    #include /etc/nginx/fastcgi.conf;
    include /etc/nginx/fastcgi_params; # REMARK: not touched
}
location = /nginx_status {
    stub_status on;
}

* section PHP SETTINGS *

cgi.fix_pathinfo=0

under directory /var/www/vhosts/system/example.com/conf
added a custom php.ini file

* php.ini contends: *

[example.com]
; Don't override following options, they are relied upon by Plesk internally

; Following options can be overridden
 chdir = /

request_slowlog_timeout = 5s
slowlog = /var/www/vhosts/example.com/logs/example.com/slowlog-example.com.log
; By default use on demand spawning (this requires php-fpm >= 5.3.9)
pm = dynamic
pm.max_children = 20
pm.process_idle_timeout = 10s
; Following pm.* options are used only when 'pm = dynamic'
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500
request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
env[HOSTNAME] = $HOSTNAME
 env[PATH] = /usr/local/bin:/usr/bin:/bin
 env[TMP] = /tmp
 env[TMPDIR] = /tmp
 env[TEMP] = /tmp
catch_workers_output = yes
pm.status_path = /status
ping.path = /ping
ping.response = bong
security.limit_extensions = .php .html

* php.ini contends end *

* configs and files end *

so far the website is working fine with this setup, all php goes through nginx/php-fpm

* now the problem to fix *
if i try to view h**p://example.com/status

all i get is
a blank page in browsers

* $ tail -f /var/log/php5-fpm.log -n 600 -s 10 *

16-Feb-2015 21:31:52] WARNING: [pool example.com] child 21532 said into stderr: "NOTICE: Access to the script '/status' has been denied (see security.limit_extensions)"

* /var/www/vhosts/example.com/logs/example.com/proxy_access_log *

xxx.xxx.xxx.xxx - - [17/Feb/2015:16:59:11 +0100] "GET /status HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:37.0) Gecko/20100101 Firefox/37.0"

* script test-php-fpm.sh: *

SCRIPT_NAME=/status 
SCRIPT_FILENAME=/status 
QUERY_STRING= 
REQUEST_METHOD=GET 
cgi-fcgi -bind -connect /var/www/vhosts/system/example.com/php-fpm.sock

script end *
$ ./test-php-fpm.sh outputs via SSH: *

Access to the script '/status' has been denied (see security.limit_extensions)
Status: 403 Forbidden
Content-type: text/html

Access denied.

* output end (blank line is there “output?” *

$ curl http://example.com/status 

just outputs NOTHING

* ls -l /var/www/vhosts/system/example.com/php-fpm.sock *

srw-rw---- 1 root psaserv 0 Feb 15 19:58 /var/www/vhosts/system/example.com/php-fpm.sock

according to several tutorials it should work, but does not.

i try searching for different solutions on the internet about
PHP-FPM NGINX and “BLANK PAGES” OR “ACCESS DENIED” errors, but nothing help.

according to this guide
(REMARK: i DID NOT COPY THE FILES mentioned there, because i wanna just use plesk)
h**p://timreeves.de/internet-technologie/server-tuning-2-nginx-und-php-fpm-unter-ubuntu-12-04-lts-und-plesk-11-5/

i also did

$ usermod -aG psacln nginx 

i do not want to go through TCP/IP, keep the socket file pls.
can someone please give me an advice.

mfg/wkr

3

Answers


  1. This may not solve your problem, but it may simplify it. Regex locations are position sensitive which can be problematic. Avoiding them in exchange for a little duplication will rule this out and allow your config to scale with fewer problems. There is also a performance advantage to using “=” locations.

    location = /status {
        allow all;
        fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
        include /etc/nginx/fastcgi_params;
    }
    
    location = /ping {
        allow all;
        fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
        include /etc/nginx/fastcgi_params;
    }
    
    location = /nginx_status {
        stub_status on;
    }
    
    Login or Signup to reply.
  2. Replace location on nginx.conf with this:

    location ~ ^/(status|ping)$
    {
        allow all;
    
        include fastcgi.conf;
        fastcgi_pass unix:/var/www/vhosts/system/example.com/php-fpm.sock;
    }
    
    Login or Signup to reply.
  3. As the error (by the php-fpm) states, the access is denied because php-fpm is limited to security.limit_extensions (in your case to .php and .html which is not what you want I think, you don’t want to parse .html as .php I guess).

    The pm.status_path is /status and it doesn’t end with .php (or .html) extension, hence the error.

    As I ran into this problem myself and found your question in google, I tell you that my solution was to set:

    pm.status_path = /status.php
    

    and use it in the nginx location too, and it works.

    The other solution would be to allow php-fpm to run any file without extension limit (empty setting to security.limit_extensions) but I don’t think it is a good idea.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search