# Help, Bad gateway 502 varnish + nginx upload file

**URL:** <https://www.ruby-forum.com/t/help-bad-gateway-502-varnish-nginx-upload-file/209777>\
**Category:** NGINX\
**Created:** [July 22, 2011, 1:12pm UTC](https://www.ruby-forum.com/t/help-bad-gateway-502-varnish-nginx-upload-file/209777 "2011-07-22T13:12:05Z")\
**Posts on this page:** 2\
**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:** [July 22, 2011, 1:12pm UTC](https://www.ruby-forum.com/t/help-bad-gateway-502-varnish-nginx-upload-file/209777/1 "2011-07-22T13:12:05Z")

</div>

Hello… i’m bew in here, first i’m sorry for my bad english and wrong  
place  
for posting.

y problem. I have a server which is installed varnish and nginx as proxy  
site and serve static pages. It run smooth, all can work together,  
apache  
for serving dynamic pages, varnish cache from apache, and nginx as  
proxy.  
Now the problem, when i upload something like attachment on my web  
email, it  
show Bad Gateway 502.  
so weird, i upload smaller file arround 100kb, show bad gateway too…  
i check the buffer and increase it, but it didn;t solve this problem…

i get an error from vhost-log nginx.  
recv() failed (104: Connection reset by peer) while reading response  
header  
from upstream.

Any clue about this? i really really appreciate who help me out this  
problem.

Thanks.

---

<div class="post-metadata">

**Author:** ![Benz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ab097/32.png) [@Benz\_C](https://www.ruby-forum.com/u/Benz_C)\
**Post date:** [July 22, 2011, 9:44pm UTC](https://www.ruby-forum.com/t/help-bad-gateway-502-varnish-nginx-upload-file/209777/2 "2011-07-22T21:44:22Z")

</div>

On Fri, Jul 22, 2011 at 7:11 AM, Benz C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> i get an error from vhost-log nginx.  
> recv() failed (104: Connection reset by peer) while reading response header  
> from upstream.
> 
> Any clue about this? i really really appreciate who help me out this  
> problem.

Does it work without varnish?

You need to use pipe() on varnish for uploads; make sure you check  
your timeout setting.

Default pipe timeout is 60 seconds, which might not be long enough.

Stefan
