# Optimize nginx stream

**URL:** <https://www.ruby-forum.com/t/optimize-nginx-stream/229491>\
**Category:** NGINX\
**Created:** [January 19, 2013, 2:31pm UTC](https://www.ruby-forum.com/t/optimize-nginx-stream/229491 "2013-01-19T14:31:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahzaib12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@shahzaib12](https://www.ruby-forum.com/u/shahzaib12)\
**Post date:** [January 19, 2013, 2:31pm UTC](https://www.ruby-forum.com/t/optimize-nginx-stream/229491/1 "2013-01-19T14:31:57Z")

</div>

we’re running high traffic streaming website similar to youtube, due to  
large number of streams on daily basis, our server is consuming 10~12TB  
bandwidh per day. We’re using nginx-1.2.1 and want to restrict users to  
download videos but don’t want to restrict streams from our website. We  
also tried "limiting download connections per ip (limit\_conn addr 1),  
but  
the problem is if 2~3 users are streaming videos from our site on same  
Lan  
with single ip, the stream will stop working for 2 others and will  
display  
(stream not found) error .I am newbie to nginx, can anyone help me on  
optimizing bandwidth security for nginx? My particular host config  
settings  
are given below :-

limit\_conn\_zone $binary\_remote\_addr zone=addr:5m;  
server {  
listen 80;  
server\_name [content.com](http://content.com);

```
    client_max_body_size 800m;

    limit_rate 100k;
# access_log /websites/theos.in/logs/access.log main;

    location / {
        root /var/www/html/site;
        index index.html index.htm index.php;

```

}  
location /files/videos {  
root /var/www/html/site;  
limit\_conn addr 1;  
}

location ~ .(flv)$ {  
flv;  
root /var/www/html/site;  
limit\_conn addr 1;  
valid\_referers none blocked [content.com](http://content.com);  
if ($invalid\_referer) {  
return 403;  
}  
}

I think the above config is enough to identify the issue. please let me  
know if you understand about what i am trying to explain.
