php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54499 FPM ping and status_path should handle HEAD request
Submitted: 2011-04-09 12:14 UTC Modified: 2011-07-02 12:35 UTC
From: danger at freebsd dot org Assigned: fat
Status: Closed Package: FPM related
PHP Version: 5.3.6 OS: FreeBSD
Private report: No CVE-ID:
 [2011-04-09 12:14 UTC] danger at freebsd dot org
Description:
------------
I have set up status_path and ping features and I verified them to give a correct output. However the php-fpm.conf states following:

"; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong"

Well that is my expectation too, as I would like to use the ping feature together with some health checking, however although it responds with the correct body set in ping.response (set to 1), the HTTP status header is set to 404:

danger@[danger-mbp ~]> curl -I http://web1/php-ping
HTTP/1.1 404 Not Found
Content-type: text/html
Date: Sat, 09 Apr 2011 10:08:28 GMT
Server: Lighttpd 1.4.x

danger@[danger-mbp ~]> curl http://web1/php-ping
1

For this reason my health checking doesn't work correctly as it expects 200 OK.

As you can see, I am using lighttpd, with the configuration from the last post from http://redmine.lighttpd.net/boards/2/topics/3923.

Expected result:
----------------
HTTP/1.1 200 OK

Actual result:
--------------
HTTP/1.1 404 Not Found

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-09 12:15 UTC] danger at freebsd dot org
the same HTTP Status code is returned for status too:

danger@[danger-mbp ~]> curl http://web1/php-status
pool:                 www
process manager:      dynamic
accepted conn:        433678
idle processes:       32
active processes:     6
total processes:      38
max children reached: 0
danger@[danger-mbp ~]> curl -I http://web1/php-status
HTTP/1.1 404 Not Found
Content-type: text/html
Date: Sat, 09 Apr 2011 10:15:15 GMT
Server: Lighttpd 1.4.x
 [2011-04-09 13:10 UTC] fat@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: fat
 [2011-04-09 13:10 UTC] fat@php.net
I've setup a similar env with nginx in front instead of lighttpd. Ping and status pages return 200 
and everything works as expected.

As you're using TCP between lighttpd and FPM, can you trace the network traffic to verify what FPM 
returns:

tcpdump -X -s 0 -i any host 127.0.0.1 and port 9000

I really think FPM will return 200, and lighttpd converts it somehow in 404. 

thx for the confirmation
 [2011-04-09 13:24 UTC] danger at freebsd dot org
-Status: Feedback +Status: Assigned
 [2011-04-09 13:24 UTC] danger at freebsd dot org
I'm actually not using tcp between fpm and lighttpd in my setup, here's my config:

$HTTP["host"] =~ "^web1$" {
      fastcgi.server = ( "/php-" =>
            (
             ( "socket" => "/tmp/php.sock",
               "check-local" => "disable",
#               "fix-root-scriptname" => "enable",
#               "broken-scriptfilename" => "enable",
             )
            )
            )
}

I also tried with combinations of "fix-root-scriptname" and "broken-scriptfilename" enabled.
 [2011-04-09 13:28 UTC] fat@php.net
-Status: Assigned +Status: Feedback
 [2011-04-09 13:28 UTC] fat@php.net
can you switch to TCP instead of unix socket to make the trace ?

I really need to be sure lighttpd is not the source of the problem.
 [2011-04-09 13:44 UTC] danger at freebsd dot org
-Status: Feedback +Status: Assigned
 [2011-04-09 13:44 UTC] danger at freebsd dot org
danger@[danger-mbp ~]> curl -I http://web1/php-ping
HTTP/1.1 404 Not Found
Content-type: text/html
Date: Sat, 09 Apr 2011 11:43:08 GMT
Server: Lighttpd 1.4.x

root@[s1-a ~]# tcpdump -i lo0 -X -s 0 -n port 9000
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo0, link-type NULL (BSD loopback), capture size 65535 bytes
13:43:08.673073 IP 172.20.100.1.33497 > 172.20.100.1.9000: Flags [SEW], seq 3323352574, win 65535, options [mss 16344,nop,wscale 3,sackOK,TS val 224959814 ecr 0], length 0
        0x0000:  4500 003c fa23 4000 8006 0000 ac14 6401  E..<.#@.......d.
        0x0010:  ac14 6401 82d9 2328 c616 55fe 0000 0000  ..d...#(..U.....
        0x0020:  a0c2 ffff 205a 0000 0204 3fd8 0103 0303  .....Z....?.....
        0x0030:  0402 080a 0d68 9d46 0000 0000            .....h.F....
13:43:08.673088 IP 172.20.100.1.9000 > 172.20.100.1.33497: Flags [S.E], seq 1543396472, ack 3323352575, win 65535, options [mss 16344,nop,wscale 3,sackOK,TS val 3210429279 ecr 224959814], length 0
        0x0000:  4500 003c fa24 4000 8006 0000 ac14 6401  E..<.$@.......d.
        0x0010:  ac14 6401 2328 82d9 5bfe 5c78 c616 55ff  ..d.#(..[.\x..U.
        0x0020:  a052 ffff 205a 0000 0204 3fd8 0103 0303  .R...Z....?.....
        0x0030:  0402 080a bf5b 435f 0d68 9d46            .....[C_.h.F
13:43:08.673097 IP 172.20.100.1.33497 > 172.20.100.1.9000: Flags [.], ack 1, win 8960, options [nop,nop,TS val 224959814 ecr 3210429279], length 0
        0x0000:  4500 0034 fa25 4000 8006 0000 ac14 6401  E..4.%@.......d.
        0x0010:  ac14 6401 82d9 2328 c616 55ff 5bfe 5c79  ..d...#(..U.[.\y
        0x0020:  8010 2300 2052 0000 0101 080a 0d68 9d46  ..#..R.......h.F
        0x0030:  bf5b 435f                                .[C_
13:43:08.673131 IP 172.20.100.1.33497 > 172.20.100.1.9000: Flags [P.], ack 1, win 8960, options [nop,nop,TS val 224959814 ecr 3210429279], length 541
        0x0000:  4502 0251 fa26 4000 8006 0000 ac14 6401  E..Q.&@.......d.
        0x0010:  ac14 6401 82d9 2328 c616 55ff 5bfe 5c79  ..d...#(..U.[.\y
        0x0020:  8018 2300 226f 0000 0101 080a 0d68 9d46  ..#."o.......h.F
        0x0030:  bf5b 435f 0101 0001 0008 0000 0001 0000  .[C_............
        0x0040:  0000 0000 0104 0001 01f5 0000 0f0e 5345  ..............SE
        0x0050:  5256 4552 5f53 4f46 5457 4152 454c 6967  RVER_SOFTWARELig
        0x0060:  6874 7470 6420 312e 342e 780b 0453 4552  httpd.1.4.x..SER
        0x0070:  5645 525f 4e41 4d45 7765 6231 1107 4741  VER_NAMEweb1..GA
        0x0080:  5445 5741 595f 494e 5445 5246 4143 4543  TEWAY_INTERFACEC
        0x0090:  4749 2f31 2e31 0b02 5345 5256 4552 5f50  GI/1.1..SERVER_P
        0x00a0:  4f52 5438 300b 0c53 4552 5645 525f 4144  ORT80..SERVER_AD
        0x00b0:  4452 3137 322e 3230 2e31 3030 2e31 0b05  DR172.20.100.1..
        0x00c0:  5245 4d4f 5445 5f50 4f52 5435 3531 3630  REMOTE_PORT55160
        0x00d0:  0b0d 5245 4d4f 5445 5f41 4444 5231 3932  ..REMOTE_ADDR192
        0x00e0:  2e31 3638 2e31 3233 2e36 0b09 5343 5249  .168.123.6..SCRI
        0x00f0:  5054 5f4e 414d 452f 7068 702d 7069 6e67  PT_NAME/php-ping
        0x0100:  0900 5041 5448 5f49 4e46 4f0f 1753 4352  ..PATH_INFO..SCR
        0x0110:  4950 545f 4649 4c45 4e41 4d45 2f75 7372  IPT_FILENAME/usr
        0x0120:  2f6c 6f63 616c 2f77 7777 2f70 6870 2d70  /local/www/php-p
        0x0130:  696e 670d 0e44 4f43 554d 454e 545f 524f  ing..DOCUMENT_RO
        0x0140:  4f54 2f75 7372 2f6c 6f63 616c 2f77 7777  OT/usr/local/www
        0x0150:  0b09 5245 5155 4553 545f 5552 492f 7068  ..REQUEST_URI/ph
        0x0160:  702d 7069 6e67 0c00 5155 4552 595f 5354  p-ping..QUERY_ST
        0x0170:  5249 4e47 0e04 5245 5155 4553 545f 4d45  RING..REQUEST_ME
        0x0180:  5448 4f44 4845 4144 0f03 5245 4449 5245  THODHEAD..REDIRE
        0x0190:  4354 5f53 5441 5455 5332 3030 0f08 5345  CT_STATUS200..SE
        0x01a0:  5256 4552 5f50 524f 544f 434f 4c48 5454  RVER_PROTOCOLHTT
        0x01b0:  502f 312e 310f 5c48 5454 505f 5553 4552  P/1.1.\HTTP_USER
        0x01c0:  5f41 4745 4e54 6375 726c 2f37 2e32 312e  _AGENTcurl/7.21.
        0x01d0:  3220 2878 3836 5f36 342d 6170 706c 652d  2.(x86_64-apple-
        0x01e0:  6461 7277 696e 3130 2e36 2e30 2920 6c69  darwin10.6.0).li
        0x01f0:  6263 7572 6c2f 372e 3231 2e32 204f 7065  bcurl/7.21.2.Ope
        0x0200:  6e53 534c 2f31 2e30 2e30 6420 7a6c 6962  nSSL/1.0.0d.zlib
        0x0210:  2f31 2e32 2e35 206c 6962 6964 6e2f 312e  /1.2.5.libidn/1.
        0x0220:  3230 0904 4854 5450 5f48 4f53 5477 6562  20..HTTP_HOSTweb
        0x0230:  310b 0348 5454 505f 4143 4345 5054 2a2f  1..HTTP_ACCEPT*/
        0x0240:  2a01 0400 0100 0000 0001 0500 0100 0000  *...............
        0x0250:  00                                       .
13:43:08.673145 IP 172.20.100.1.9000 > 172.20.100.1.33497: Flags [.], ack 542, win 8892, options [nop,nop,TS val 3210429279 ecr 224959814], length 0
        0x0000:  4500 0034 fa27 4000 8006 0000 ac14 6401  E..4.'@.......d.
        0x0010:  ac14 6401 2328 82d9 5bfe 5c79 c616 581c  ..d.#(..[.\y..X.
        0x0020:  8010 22bc 2052 0000 0101 080a bf5b 435f  .."..R.......[C_
        0x0030:  0d68 9d46                                .h.F
13:43:08.673423 IP 172.20.100.1.9000 > 172.20.100.1.33497: Flags [P.], ack 542, win 8959, options [nop,nop,TS val 3210429279 ecr 224959814], length 80
        0x0000:  4502 0084 fa28 4000 8006 0000 ac14 6401  E....(@.......d.
        0x0010:  ac14 6401 2328 82d9 5bfe 5c79 c616 581c  ..d.#(..[.\y..X.
        0x0020:  8018 22ff 20a2 0000 0101 080a bf5b 435f  .."..........[C_
        0x0030:  0d68 9d46 0106 0001 0032 0600 5374 6174  .h.F.....2..Stat
        0x0040:  7573 3a20 3430 3420 4e6f 7420 466f 756e  us:.404.Not.Foun
        0x0050:  640d 0a43 6f6e 7465 6e74 2d74 7970 653a  d..Content-type:
        0x0060:  2074 6578 742f 6874 6d6c 0d0a 0d0a 0000  .text/html......
        0x0070:  0000 0000 0103 0001 0008 0000 0000 0000  ................
        0x0080:  003a 2020                                .:..
13:43:08.673432 IP 172.20.100.1.33497 > 172.20.100.1.9000: Flags [.], ack 81, win 8950, options [nop,nop,TS val 224959814 ecr 3210429279], length 0
        0x0000:  4500 0034 fa29 4000 8006 0000 ac14 6401  E..4.)@.......d.
        0x0010:  ac14 6401 82d9 2328 c616 581c 5bfe 5cc9  ..d...#(..X.[.\.
        0x0020:  8010 22f6 2052 0000 0101 080a 0d68 9d46  .."..R.......h.F
        0x0030:  bf5b 435f                                .[C_
13:43:08.673436 IP 172.20.100.1.9000 > 172.20.100.1.33497: Flags [F.], seq 81, ack 542, win 8959, options [nop,nop,TS val 3210429279 ecr 224959814], length 0
        0x0000:  4500 0034 fa2a 4000 8006 0000 ac14 6401  E..4.*@.......d.
        0x0010:  ac14 6401 2328 82d9 5bfe 5cc9 c616 581c  ..d.#(..[.\...X.
        0x0020:  8011 22ff 2052 0000 0101 080a bf5b 435f  .."..R.......[C_
        0x0030:  0d68 9d46                                .h.F
13:43:08.673442 IP 172.20.100.1.33497 > 172.20.100.1.9000: Flags [.], ack 82, win 8960, options [nop,nop,TS val 224959814 ecr 3210429279], length 0
        0x0000:  4500 0034 fa2b 4000 8006 0000 ac14 6401  E..4.+@.......d.
        0x0010:  ac14 6401 82d9 2328 c616 581c 5bfe 5cca  ..d...#(..X.[.\.
        0x0020:  8010 2300 2052 0000 0101 080a 0d68 9d46  ..#..R.......h.F
        0x0030:  bf5b 435f                                .[C_
13:43:08.673451 IP 172.20.100.1.33497 > 172.20.100.1.9000: Flags [F.], seq 542, ack 82, win 8960, options [nop,nop,TS val 224959814 ecr 3210429279], length 0
        0x0000:  4500 0034 fa2c 4000 8006 0000 ac14 6401  E..4.,@.......d.
        0x0010:  ac14 6401 82d9 2328 c616 581c 5bfe 5cca  ..d...#(..X.[.\.
        0x0020:  8011 2300 2052 0000 0101 080a 0d68 9d46  ..#..R.......h.F
        0x0030:  bf5b 435f                                .[C_
13:43:08.902948 IP 172.20.100.1.33497 > 172.20.100.1.9000: Flags [F.], seq 542, ack 82, win 8960, options [nop,nop,TS val 224960044 ecr 3210429279], length 0
        0x0000:  4500 0034 fb40 4000 8006 0000 ac14 6401  E..4.@@.......d.
        0x0010:  ac14 6401 82d9 2328 c616 581c 5bfe 5cca  ..d...#(..X.[.\.
        0x0020:  8011 2300 2052 0000 0101 080a 0d68 9e2c  ..#..R.......h.,
        0x0030:  bf5b 435f                                .[C_
13:43:08.902959 IP 172.20.100.1.9000 > 172.20.100.1.33497: Flags [R], seq 1543396554, win 0, length 0
        0x0000:  4500 0028 fb41 4000 8006 0000 ac14 6401  E..(.A@.......d.
        0x0010:  ac14 6401 2328 82d9 5bfe 5cca 0000 0000  ..d.#(..[.\.....
        0x0020:  5004 0000 2046 0000                      P....F..
 [2011-04-09 13:59 UTC] fat@php.net
-Status: Assigned +Status: Feedback
 [2011-04-09 13:59 UTC] fat@php.net
OK FPM returns 404.

What is your FPM status and ping related configuration please ?
 [2011-04-09 14:04 UTC] danger at freebsd dot org
-Status: Feedback +Status: Assigned
 [2011-04-09 14:04 UTC] danger at freebsd dot org
I guess it's pretty standard:

pm.status_path = /php-status
ping.path = /php-ping
ping.response = 1
 [2011-04-09 14:29 UTC] danger at freebsd dot org
OK, I know what is going on here. I just found that curl -I does a HEAD request, so `curl -I http://web1/php-(ping/status)' returns 404, but when I use -i it works fine:

danger@[danger-mbp ~]> curl -i http://web1/php-ping
HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked
Date: Sat, 09 Apr 2011 12:25:01 GMT
Server: Lighttpd 1.4.x

1

So it seems FPM works correct, although it might be nice to return with 200 OK for HEAD requests as well. Sorry for inconvenience.
 [2011-04-09 15:54 UTC] fat@php.net
-Summary: FPM ping and status_path return HTTP 404 even though I get the correct output +Summary: FPM ping and status_path should handle HEAD request -Type: Bug +Type: Feature/Change Request
 [2011-04-09 15:54 UTC] fat@php.net
OK

so this is not a bug, this is a feature/change request. ping and status page 
should returns 200OK on HEAD requests
 [2011-07-02 12:34 UTC] fat@php.net
Automatic comment from SVN on behalf of fat
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=312813
Log: - Implemented FR #54499 (FPM ping and status_path should handle HEAD request)
 [2011-07-02 12:35 UTC] fat@php.net
-Status: Assigned +Status: Closed
 [2011-07-02 12:35 UTC] fat@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

fixed !
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 13:01:59 2014 UTC