# Nginx truncate files than 1G

**URL:** <https://www.ruby-forum.com/t/nginx-truncate-files-than-1g/221290>\
**Category:** NGINX\
**Created:** [July 7, 2012, 2:49pm UTC](https://www.ruby-forum.com/t/nginx-truncate-files-than-1g/221290 "2012-07-07T14:49:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 7, 2012, 2:49pm UTC](https://www.ruby-forum.com/t/nginx-truncate-files-than-1g/221290/1 "2012-07-07T14:49:38Z")

</div>

Hi my nginx truncate files than 1 G

Posted at Nginx Forum:

> **[Nginx truncate files than 1G](https://forum.nginx.org/read.php?2,228356,228356#msg-228356)**
>
> Hi my nginx truncate files than 1 G

---

<div class="post-metadata">

**Author:** ![Adrian\_Janeczek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@Adrian\_Janeczek](https://www.ruby-forum.com/u/Adrian_Janeczek)\
**Post date:** [July 8, 2012, 12:43am UTC](https://www.ruby-forum.com/t/nginx-truncate-files-than-1g/221290/2 "2012-07-08T00:43:19Z")

</div>

-------- Original-Nachricht --------

> Datum: Sat, 7 Jul 2012 08:49:02 -0400 (EDT)  
> Von: “Adrian Janeczek” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> An: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> Betreff: Nginx truncate files than 1G

> Hi my nginx truncate files than 1 G

Wow! So much information at once? I am not sure if we here can  
handle that much information!

Would it be possible for you to provide at least some minimal  
information like what version of nginx you are using, what arch, what  
exactly you are trying to do, nginx configuration, etc…

---

<div class="post-metadata">

**Author:** ![Adrian\_Janeczek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@Adrian\_Janeczek](https://www.ruby-forum.com/u/Adrian_Janeczek)\
**Post date:** [July 8, 2012, 11:24am UTC](https://www.ruby-forum.com/t/nginx-truncate-files-than-1g/221290/3 "2012-07-08T11:24:47Z")

</div>

Hello!

On Sat, Jul 07, 2012 at 08:49:02AM -0400, Adrian Janeczek wrote:

> Hi my nginx truncate files than 1 G

Most likely it’s due to your backend closing connection due to  
timeout, as nginx stop receiving response for a while when it hits  
proxy\_max\_temp\_file\_size, which is 1G by default.

Possible solutions are:

1. Use lower proxy\_max\_temp\_file\_size to avoid timeouts on  
backends. You may even want to disable disk buffering completely,  
by using “proxy\_max\_temp\_file\_size 0;”.

2. Use bigger proxy\_max\_temp\_file\_size to make sure responses are  
always buffered by nginx.

3. Use bigger timeouts on your backend.

See here for more details:

> **[Module ngx\_http\_proxy\_module](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_max_temp_file_size)**
>
> The ngx\_http\_proxy\_module module allows passing requests to another server.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Adrian\_Janeczek](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/59ef9b/32.png) [@Adrian\_Janeczek](https://www.ruby-forum.com/u/Adrian_Janeczek)\
**Post date:** [July 8, 2012, 11:56am UTC](https://www.ruby-forum.com/t/nginx-truncate-files-than-1g/221290/4 "2012-07-08T11:56:19Z")

</div>

On 08.07.2012 12:24, Maxim D. wrote:

> by using “proxy\_max\_temp\_file\_size 0;”.
> 
> 1. Use bigger proxy\_max\_temp\_file\_size to make sure responses are  
> always buffered by nginx.
> 
> 2. Use bigger timeouts on your backend.
> 
> See here for more details:
> 
> [Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_max_temp_file_size)

1. send static content directly by nginx, without backend server at all  
(proxy to backend only requests to dynamic content: \*.php, etc)

2. or use X-Accel-Redirect at backend to avoid full transfer of file  
([[lang\_en]Using X-Accel-Redirect in Nginx to Implement Controlled Downloads[/lang\_en][lang\_ru]Использование X-Accel-Redirect с Nginx для реализации контролируемых скачиваний[/lang\_ru] - Oleksiy Kovyrin :: Oleksiy Kovyrin](http://kovyrin.net/2006/11/01/nginx-x-accel-redirect-php-rails/))

3. or use [GitHub - defanator/mod\_aclr2: Module for Apache 2.x which automates serving static content with NGINX local proxy · GitHub](https://github.com/defanator/mod_aclr2)

–  
Best regards,  
Gena
