# HEAD requests with PHP-FPM

**URL:** <https://www.ruby-forum.com/t/head-requests-with-php-fpm/228089>\
**Category:** NGINX\
**Created:** [April 9, 2013, 9:00am UTC](https://www.ruby-forum.com/t/head-requests-with-php-fpm/228089 "2013-04-09T09:00:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![F21](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/2bfe46/32.png) [@F21](https://www.ruby-forum.com/u/F21)\
**Post date:** [April 9, 2013, 9:00am UTC](https://www.ruby-forum.com/t/head-requests-with-php-fpm/228089/1 "2013-04-09T09:00:56Z")

</div>

I would like to be able to support HEAD requests. For the most part,  
HEAD  
works well with static files. However, if I am trying to use a HEAD  
request  
against a PHP file, it is missing the Content-Length or the  
Transfer-Encoding header.

PHP-FPM is connected to nginx 1.2.8 using FCGI. I also have gzip  
enabled.

user www-user;  
worker\_processes 1;

error\_log logs/error.log info;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;

```
default_type application/octet-stream;
client_max_body_size 10M;

sendfile on;
keepalive_timeout 65;

gzip on;
gzip_types text/plain text/css application/json 

```

application/javascript  
application/x-javascript text/javascript;

```
server {
   server_name test.com;
   root /web;

   location ~ \.php$ {

```

fastcgi\_intercept\_errors on;  
fastcgi\_pass unix:/run/php/php-fpm.sock;  
fastcgi\_index index.php;  
fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;  
include fastcgi\_params;

```
   }

   listen 80 default_server;

   error_page 500 502 503 504 /50x.html;

}

```

}

If I use a GET, everything works as expected:

$ curl -XGET [http://test.com/phpinfo.php](http://test.com/phpinfo.php) -I  
HTTP/1.1 200 OK  
Date: Tue, 09 Apr 2013 06:58:50 GMT  
Content-Type: text/html  
Transfer-Encoding: chunked \<-------------------  
Connection: keep-alive

But, if I use a HEAD, Transfer-Encoding is missing:

$ curl -XHEAD [http://test.com/phpinfo.php](http://test.com/phpinfo.php) -I  
HTTP/1.1 200 OK  
Date: Tue, 09 Apr 2013 06:59:24 GMT  
Content-Type: text/html  
Connection: keep-alive

What’s the reason for nginx not including the Transfer-Encoding header?  
Is  
there anyway to turn it on? Interestingly, if I try and set the  
Transfer-Encoding header inside the PHP script, it is still removed by  
nginx.

Posted at Nginx Forum:

> **[HEAD requests with PHP-FPM](https://forum.nginx.org/read.php?2,238218,238218#msg-238218)**
>
> I would like to be able to support HEAD requests. For the most part, HEAD works well with static files. However, if I am trying to use a HEAD request against a PHP file, it is missing the Content-Length or the Transfer-Encoding header. PHP-FPM is...
