# Nginx file straming

**URL:** <https://www.ruby-forum.com/t/nginx-file-straming/215298>\
**Category:** NGINX\
**Created:** [December 29, 2011, 7:20pm UTC](https://www.ruby-forum.com/t/nginx-file-straming/215298 "2011-12-29T19:20:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [December 29, 2011, 7:20pm UTC](https://www.ruby-forum.com/t/nginx-file-straming/215298/1 "2011-12-29T19:20:33Z")

</div>

Hello  
I have problem with nginx  
When my server sream big files + 1024MB via firefox or other browser the  
connect is reseting (file szise is 4gb but download only 1000 - 1157)  
I use php-fpm

dominian conf

upstream php\_fpm {  
server unix:/var/run/php-fpm/php-fpm.sock;  
}

server  
{  
listen 80;  
server\_name [v10.server.me](http://v10.server.me);

access\_log /var/log/nginx/access.log;  
error\_log /var/log/nginx/error.log;

proxy\_buffers 8 16k;  
proxy\_buffer\_size 32k;

client\_header\_timeout 120;  
client\_body\_timeout 120;  
send\_timeout 120;

```
location /
{
  root /var/www;
  index index.php index.html index.htm;
error_page 404 = http://direct.rapidox.pl/404.php;
#error_page 502 503 504 = http://direct.rapidox.pl/502.php;
rewrite ^/file/([^/]+)/(.*)$ /download.php?kod=$1&filename=$2 last;
location ~ .php$
    {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass php_fpm;
        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 128k;  
fastcgi\_buffers 4 256k;  
fastcgi\_busy\_buffers\_size 256k;  
fastcgi\_temp\_file\_write\_size 256k;  
}

```
location = /php_status {
  include /etc/nginx/fastcgi_params;
  fastcgi_param SCRIPT_FILENAME /php_status;
  fastcgi_pass php_fpm;
  access_log off;
}

location /nginx_status {
  stub_status on;
  access_log off;
}

```

}  
}  
and nginx.conf  
user www-data;  
worker\_processes 2;  
worker\_rlimit\_nofile 16384;  
worker\_rlimit\_sigpending 32768;  
worker\_priority -5;  
#worker\_cpu\_affinity 01000000 00100000 00010000 10000000 00001000  
00000100 00000010 00000001;

pid /var/run/nginx.pid;

events {  
worker\_connections 2048;  
multi\_accept on;  
use epoll;  
}

http {

## 

# Basic Settings

## 

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

# server\_names\_hash\_bucket\_size 64;

# server\_name\_in\_redirect off;

include /etc/nginx/mime.types;  
default\_type application/octet-stream;

## 

# Logging Settings

## 

access\_log /var/log/nginx/access.log;  
error\_log /var/log/nginx/error.log;

## 

# Gzip Settings

## 

gzip on;  
gzip\_disable “msie6”;

# gzip\_vary on;

# gzip\_proxied any;

# gzip\_comp\_level 6;

# gzip\_buffers 16 8k;

# gzip\_http\_version 1.1;

# gzip\_types text/plain text/css application/json

application/x-javascript text/xml application/xml application/xml+rss  
text/javascript;

include /etc/nginx/sites-enabled/\*;  
}

and fpm worker conf  
[www]  
listen = /var/run/php-fpm/php-fpm.sock  
;listen.backlog = -1  
;listen.allowed\_clients = 127.0.0.1  
listen.owner = www-data  
listen.group = www-data  
;listen.mode = 0666  
user = www-data  
group = www-data  
pm = dynamic  
pm.max\_requests = 0  
pm.max\_children = 75  
pm.start\_servers = 10  
pm.min\_spare\_servers = 10  
pm.max\_spare\_servers = 50  
pm.status\_path = /php\_status  
php\_admin\_value[sendmail\_path] = /usr/sbin/sendmail -t -i -f  
removed\_email\_address@domain.invalid  
php\_flag[display\_errors] = On  
php\_admin\_value[memory\_limit] = 1024M

and fpm conf

;;;;;;;;;;;;;;;;;;;;;  
; FPM Configuration ;  
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP’s  
install  
; prefix (/usr). This prefix can be dynamicaly changed by using the  
; ‘-p’ argument from the command line.

; Include one or more files. If glob(3) exists, it is used to include a  
bunch of  
; files from a glob(3) pattern. This directive can be used everywhere in  
the  
; file.  
; Relative path can also be used. They will be prefixed by:  
; - the global prefix if it’s been set (-p arguement)  
; - /usr otherwise  
;include=/etc/php5/fpm/\*.conf

;;;;;;;;;;;;;;;;;;  
; Global Options ;  
;;;;;;;;;;;;;;;;;;

[global]  
; Pid file  
; Note: the default prefix is /var  
; Default Value: none  
pid = /var/run/php5-fpm.pid

; Error log file  
; Note: the default prefix is /var  
; Default Value: log/php-fpm.log  
error\_log = /var/log/php5-fpm.log

; Log level  
; Possible Values: alert, error, warning, notice, debug  
; Default Value: notice  
;log\_level = notice

; If this number of child processes exit with SIGSEGV or SIGBUS within  
the time  
; interval set by emergency\_restart\_interval then FPM will restart. A  
value  
; of ‘0’ means ‘Off’.  
; Default Value: 0  
;emergency\_restart\_threshold = 0

; Interval of time used by emergency\_restart\_interval to determine when

; a graceful restart will be initiated. This can be useful to work  
around  
; accidental corruptions in an accelerator’s shared memory.  
; Available Units: s(econds), m(inutes), h(ours), or d(ays)  
; Default Unit: seconds  
; Default Value: 0  
;emergency\_restart\_interval = 0

; Time limit for child processes to wait for a reaction on signals from  
master.  
; Available units: s(econds), m(inutes), h(ours), or d(ays)  
; Default Unit: seconds  
; Default Value: 0  
;process\_control\_timeout = 0

; Send FPM to background. Set to ‘no’ to keep FPM in foreground for  
debugging.  
; Default Value: yes  
;daemonize = yes

; Set open file descriptor rlimit for the master process.  
; Default Value: system defined value  
;rlimit\_files = 1024

; Set max core size rlimit for the master process.  
; Possible Values: ‘unlimited’ or an integer greater or equal to 0  
; Default Value: system defined value  
;rlimit\_core = 0

;;;;;;;;;;;;;;;;;;;;  
; Pool Definitions ;  
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different  
listening  
; ports and different management options. The name of the pool will be  
; used in logs and stats. There is no limitation on the number of pools  
which  
; FPM can handle. Your system will tell you anyway 🙂

; To configure the pools it is recommended to have one .conf file per  
; pool in the following directory:  
include=/etc/php5/fpm/pool.d/\*.conf

files is streaming via curl  
i dont have any idea  
and my logs are clean ( i don’t see any probem)  
i trayed debug mode but this isn’t helpfull

Posted at Nginx Forum:

> **[nginx file straming](https://forum.nginx.org/read.php?2,220679,220679#msg-220679)**
>
> Hello I have problem with nginx When my server sream big files + 1024MB via firefox or other browser the connect is reseting (file szise is 4gb but download only 1000 - 1157) I use php-fpm dominian conf upstream php\_fpm { server unix:/var/ru
