# Disable HEAD + Good config for large files?

**URL:** <https://www.ruby-forum.com/t/disable-head-good-config-for-large-files/214546>\
**Category:** NGINX\
**Created:** [December 5, 2011, 1:40pm UTC](https://www.ruby-forum.com/t/disable-head-good-config-for-large-files/214546 "2011-12-05T13:40:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [December 5, 2011, 1:40pm UTC](https://www.ruby-forum.com/t/disable-head-good-config-for-large-files/214546/1 "2011-12-05T13:40:03Z")

</div>

Hi everyone!

Over the past weeks I read a lot on your pages and blogs on the net but  
I still have some questions left that seem to be unanswered until now.

My site is acting like some kind of proxy and transfers big files (up to  
several GB) from a remote site to the user. What the script actually  
does is read 4096 byte, write what was read and flush the buffer. Then  
start over till remote file is read completely.

Code is written in php. I previously used Apache to do the work but  
nginx performs much better in any case. However, when using HEAD instead  
of GET with Apache I recognized that even though the custom header is  
already flush()ed by the php script Apache will not release the file  
until the php script ended. With this only a few head requests will  
congest the incoming bandwidth of the server.

For Apache I found this solution:  
RewriteEngine on  
RewriteCond %{REQUEST\_METHOD}  
^(TRACE|TRACK|OPTIONS|HEAD)  
RewriteRule .\* - [F,L]

Is nginx behaving the same as Apache did before?

How would the config for apache look like in nginx? (As the code above  
is not mine and I’m not good at rewrite rules, please provide me an  
example or where to look.)

For the same project I also recognized that the servers speed will drop  
a bit for every user once I reach about 150 - 200 connections (according  
to nginx status). The servers are doing around 30 - 50 MByte/s in and  
out (so 60 - 100 MByte/s in total) on gigabit lines and even on 10  
gigabit lines. The thing is, that munin (monitoring tool) shows me about  
6k to 8k interrupts on eth0 for the time speeds are not as they should  
be. I tried several server providers and most servers look the same or  
even worse. So… who to blame? All server provider lines are bad? Too  
many interrupts for eth0? Wrong nginx config?

I’m running nginx 1.0.10 (latest stable) and php-fpm on ubuntu 10.04  
server edition.

# nginx.conf:

user www-data;  
worker\_processes 6; #6 cores cpu used in this case  
pid /var/run/nginx.pid;

events {  
worker\_connections 256;  
}

http {  
sendfile on;  
tcp\_nopush on;  
tcp\_nodelay on;  
keepalive\_timeout 0;  
types\_hash\_max\_size 2048;  
server\_tokens off;

```
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    gzip off;

```

# }

# sites-available/default:

server {  
index index.php;

```
    server_name some.servername.com;

    access_log /var/log/nginx/localhost.access.log;

    location / {
            root /var/www;
            index index.php;
    }

    location /nginx_status {
            stub_status on;
            access_log off;
            allow 127.0.0.1;
            deny all;
    }

    ## Disable viewing certain directorys
    location ~ /(dir1|dir2|dir3) {
           deny all;
           return 404;
    }

    ## Images and static content is treated different
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
            root /var/www;
            access_log off;
            expires 30d;
    }
    ## Parse all .php file in the /var/www directory
    location ~ .php$ {
            root /var/www;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_pass backend;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME

```

$document\_root$fastcgi\_script\_name;  
include fastcgi\_params;  
fastcgi\_param QUERY\_STRING $query\_string;  
fastcgi\_param REQUEST\_METHOD $request\_method;  
fastcgi\_param CONTENT\_TYPE $content\_type;  
fastcgi\_param CONTENT\_LENGTH $content\_length;  
fastcgi\_intercept\_errors on;  
fastcgi\_ignore\_client\_abort off;  
fastcgi\_connect\_timeout 60;  
fastcgi\_send\_timeout 180;  
fastcgi\_read\_timeout 180;  
fastcgi\_buffer\_size 4k;  
fastcgi\_buffers 8 64k;  
fastcgi\_busy\_buffers\_size 256k;  
#fastcgi\_temp\_file\_write\_size 256k;  
fastcgi\_max\_temp\_file\_size 0;  
}

```
    ## Disable viewing .htaccess & .htpassword
    location ~ /\.ht {
           deny all;
           return 404;
    }

```

}

# upstream backend { server 127.0.0.1:9000; }

If I forgot  
I would be glad for any advice and help.

Posted at Nginx Forum:

> **[Disable HEAD + Good config for large files?](https://forum.nginx.org/read.php?2,219630,219630#msg-219630)**
>
> Hi everyone! Over the past weeks I read a lot on your pages and blogs on the net but I still have some questions left that seem to be unanswered until now. My site is acting like some kind of proxy and transfers big files (up to several GB) from a...
